51 microcontroller and hxd019 communication
All IO MCU internal pull-down and remote IC_HXD019 connected to Set_SDA_IO (GetBUSYStatus) to close, (all) the main control chip and hxd019 connected to the pin pin set function set, respectively is the hardware on the SDA, SCL, BUSy power or standby are high, then add the compiler;
1, send learning data or library data:
1.1. data obtained from the library (Size variable length, up to 120 bytes, learning data is 232 bytes) example:
unsigned char data[]={0x30,0x00,0x01,0x1c,0xE3,0x00,0xFF,0x20,0x88,0xD7}
1.2.Then write function: writeI2C(data, 10):
2,Learning and learning data,hyxx.cfile:
2.1 Access to learning: master if the data obtained from the upper layer: the first two bytes
0x30,0x20,The given function Learn_start2();
(At this time the external operation: with the remote control to the infrared diode code, not more than 20 seconds to learn, HXD019 timeout);
2.2 And so on: when IO:busy From low to high,Call function call function readI2C2(),Master write their own example:
LLearn_start2();
Delay10ms(10);
while(BUSY==0)
Delay10ms(1);
if(BUSY==1)
{
readI2C2(ReceiveBuf1); //进After learning,busyRead data from low to high
Delay10ms(10 ); ......
Data obtained readtempbuf[]={},230 Byte;Process back to the upper or the master (the latter case): the first byte will be read 00 Get rid of,Front plus 30 03 Add check,30Start with all data and low 8 bits put 232 byte,30 03 +(00 229 individual byte)+check(All previous data and low 8 bits),When used to send back 019 chips,Function name writeI2C(),This example is learning data for 232 bytes,If the database data SizeThere may be changes according to the actual code value;
3,Hardware dependent:
The hardware is connected, in the debugging period, it is recommended that the three communications IO port, the string of a 100R resistor (production does not need), to prevent abnormal IO conflict.
4,Timing adjustment hyxx.c file,
Refer to the timing reference map.JPG> document: according to the different clock adjustment MCU, measuring the communication clock SCL line parameters:
#define DELAY_TIME 15// When the SCL clock cycle is called writeI2C ():H=30uS,
#define DELAY_ST 20//hxd;SCL the first falling edge to the second falling edge of time:20mS,
Note: if the program calls writeI2C () and Learn_start2 (busy) when the interval between the 800mS, (Learn_start2) (after) to check whether or not to become high: to be more than 50mS intervals