| ??? 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 |



