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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/15/09 06:57
Read: times


 
#165365 - Dear stefan and david
Responding to: ???'s previous message
I know you guys are going the right way but i still have doubts asto what i should do. As stefan gave me the code, i used it ditto as it was given, but i can read only 80, 80, 80 in all the registers.

I will ask one more thing. as stefan pointed ourt that i have 15 pulses and i too have checked that i have 15 pulses instead of the 16 shown in the datasheet. BUT, in the datasheet, on page 8 in the last two lines, it is written that "The first data bit to be transmitted at the first falling edge after the last last bit of command is written". So this would mean that the adress will be transmitted on the first 8 low to high transformations and then we will recieve the data from the HT1380 in the ery next 8 high to low pulses.

Now in the picture that i have attached, the first is what my old code looks like and the second picture is what my wave will look like if i use stefan's function.

This is what's confusing me.....not that my loop is working ...it's still not.....

pleasee give me your email so that i can send the IMAGE showing both the waveforms....



//******************************************************************* 
//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; 
 
SCLK=0; 
DATA_IO = sending_bit; //Clock to DATA_IO delay is 250ns (max) 
comparing_byte=comparing_byte<<1; 
SCLK=1;	//data entered on rising edge !!!
SCLK=1;	//added zzzzzzzzz
} 

DATA_IO=1; //Making the pin of the MCU as an input pin		
SCLK=0; //**At this high to low transition, we would recieve the LSB of the data that we want to read as from the DATASHEET page 8 last 2 lines

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; 

for(i=0;i<8;i++) 
{ 
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; 
SCLK=1;
SCLK=1;
} 
SCLK=0; // the SCLK is lowered once the loop is complete
SCLK=0;
DATA_IO=0; // the data pin is again made normal
return(received_data); 
} 

 



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