Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/14/09 14:54
Read: times


 
#165341 - keep SCLK low and...pen&paper and...
Responding to: ???'s previous message
1)If You try Your pen/paper setup again , You will find that on every access (in Your infinite loop) SCLK forms 15 bits in RESET envelope.
2)Draw timediagrams , generated by code, and compare with holteck's behavior.
3)See below what changes i suppose:

//******************************************************************* 
//FUNCTION THAT SENDS ADDRESS OR DATA_IO AFTER CONVERTING IT TO BITS 
//******************************************************************* 
void convert_and_send(unsigned char hex_data1) 
{ 
bit sending_bit; 
unsigned char comparing_byte=0x01; 
unsigned char i; 
unsigned char storing_byte=0x00; 
SBUF=hex_data1; 
usec_wait(5); 

for(i=0;i<8;i++) 
{ 
storing_byte=(hex_data1&comparing_byte); 
if(storing_byte==0x00) 
sending_bit=0; 
else 
sending_bit=1; 
//zzzzzzzz omit SCLK=0; 
SCLK=0; 
DATA_IO = sending_bit; //Clock to DATA_IO delay is 250ns (max) 
comparing_byte<<=1; 
SCLK=1; //data entered on rising edge !!!
SCLK=1; //added zzzzzzzzz
SCLK=0; /added  zzzzzzzzzz
DATA_IO = 1 //added zzzzz HOLTEK code keeps data io LOW too
            // for 8051 is needed HIGH
} 
serial_storage=0x00; 
usec_wait(2); 
} 


//************************************************************************************** 
//FUNCTION THAT RECEIVES DATA AND THEN CONVERTS IT TO CHARACTER AND PASSES TO ITS CALLER 
//************************************************************************************** 
unsigned char receive_convert(void) 
{ 

bit receiving_bit; 
unsigned char comparing_byte=0x00; 
unsigned char i=0; 
unsigned char received_data=0x00; 

DATA_IO=1 ;//added zzzzzz

for(i=0;i<8;i++) 
{ 
SCLK=1; 
SCLK=1; //For giving a DEALY 
SCLK=0; 
SCLK=0; //added zzzz  DATA outputed on FALLING edge 

receiving_bit=DATA_IO;

if(receiving_bit==0) 
comparing_byte=0x00; 
else 
comparing_byte=0x80; //comparing byte is 10000000 as the bit is to be placesd in the MSB position 
received_data=received_data>>1; 
received_data=received_data|comparing_byte; 
} 
return(received_data); 
} 


 

regards


List of 39 messages in thread
TopicAuthorDate
Interfacing HT1380 with 89C51 in C            01/01/70 00:00      
   It looks like you should read when clock is high            01/01/70 00:00      
      Dear David            01/01/70 00:00      
         Yes. You read after the -ve edge.            01/01/70 00:00      
            Should shift before assign            01/01/70 00:00      
               Dear Per            01/01/70 00:00      
                  Dear Ackhil,            01/01/70 00:00      
                     Amazing . . . ! ! !            01/01/70 00:00      
                        Are you a young man ?            01/01/70 00:00      
            David            01/01/70 00:00      
   keep SCLK low when idle            01/01/70 00:00      
      Dear Stefan            01/01/70 00:00      
         re            01/01/70 00:00      
            Dear Stefan            01/01/70 00:00      
   Still no luck ! !            01/01/70 00:00      
      Code?            01/01/70 00:00      
         Sorry for the incorrect post            01/01/70 00:00      
            Please format your code            01/01/70 00:00      
      keep SCLK low and...pen&paper and...            01/01/70 00:00      
   Dear stefan and david            01/01/70 00:00      
      Do you expect people to format and correct code every t            01/01/70 00:00      
         true 99% of the time            01/01/70 00:00      
            a neat program makes a happy programmer            01/01/70 00:00      
         I tried a pen and paper            01/01/70 00:00      
            'arranging' is good, but how about comments?            01/01/70 00:00      
               I'll improve on that front as well ! !            01/01/70 00:00      
      Hi Akhil , check this            01/01/70 00:00      
         Dear Stefan            01/01/70 00:00      
            Dear Stefan            01/01/70 00:00      
               Congratulations. a good write() and read()            01/01/70 00:00      
                  no luck            01/01/70 00:00      
                     You can always send a clock from 8051.            01/01/70 00:00      
                        i'll do that ! !            01/01/70 00:00      
                        Dear David            01/01/70 00:00      
                           at least X2 must be free, not grounded            01/01/70 00:00      
                           32Mhz ?!            01/01/70 00:00      
                           Do it carefully            01/01/70 00:00      
                              Dear David            01/01/70 00:00      
                                 I am sure it is something simple.            01/01/70 00:00      

Back to Subject List