HXD019 Driver for 8051 MCUs

Published 2017-02-18Views 1555views

51 MCU driver example, communicate with hxd019 through three GPIO ports or I2C, with ready-made read and write routines.

Article

 

                                           Communication Instructions for 51 MCU and hxd019 

0. Set three GPIOs and initialize, hyxx.cFile:

     WillThe internal pull-down of all IOs connected between the MCU and the remote control IC_HXD019 needs to be disabled,Set_SDA_IO() to GetBUSYStatusAll main control chips of () andhxd019ConnectedpinPin setting functionSet properly, which correspond to the hardware respectivelySDA,SCL,BUSyHigh level at power-on or standby, then Add to compilation;

1. Send learning data or code library data:

1.1.FromCode libraryObtained data (SizeVariable length, maximum 120 bytes, the learning data is 232 bytes)Example:

unsigned char  data[]={0x30,0x00,0x01,0x1c,0xE3,0x00,0xFF,0x20,0x88,0xD7}

1.2.Then call the write function: writeI2C(data, 10): 

2. Learn and send learning data,hyxx.cFile:

2.1  Enter learning mode:Main controlIf fromUpper layerObtained data: The first two bytes are0x30,0x20,ThenCall the provided function once  Learn_start2();

(External operation at this time: Point the remote control to be learned at the infrared diode to send codes. If no learning is performed for more than about 20 seconds,learning will not be performed,HXD019 times out);

2.2   Wait for learning to complete: When the IO port: busy portFrom lowto high, call the function immediately Call functionreadI2C2(), written independently by the main control, example:

                   LLearn_start2();

Delay10ms(10);

while(BUSY==0)

Delay10ms(1);

if(BUSY==1)

{

readI2C2(ReceiveBuf1);  //After entering learning mode,busyChanges from low to high, read data

Delay10ms(10 );

                        ......

Obtained datareadtempbuf[]={},230 bytes; sent back toUpper layeror processed by the main control itself (the latter is the case in this example): Remove the first byte 00 read, add 30 03 and checksum in front. The lower 8 bits of the sum of all data starting from 30 are placed in the 232nd byte, 30 03 + (229 bytes) + checksum (lower 8 bits of the sum of all previous data). When needed, send it back to the 019 chip, function name00  This example is learning data, which iswriteI2C(),232 bytes. If the size of the code library data may change, fill it in according to the actual code value;3. Hardware related:

Connect the hardware properly

  , during debugging, it is recommended to connect a resistor of about 100R in series for each of the three communication IO ports (not required for mass production) to prevent abnormal IO conflicts.4. Timing adjustment, in

File,hyxx.cRefer to <

 

Timing Reference Diagram.JPG> document: Adjust according to different MCU clocks. Test the communication clock SCL line and adjust the following parameters:// MakeThe clock cycle when calling

 

       #define  DELAY_TIME  15writeI2C(): H=SCLTime from the first falling edge to the second falling edge:Note: When debugging the program, if30uS,

       #define  DELAY_ST  20//hxd;SCLcontinuously call20mS,

 

 writeI2C() and Learn_start, there must be an interval between them() before checking whether busy goes high:2()An interval of more than 50mS is required.800mS, Learn_start2Communication Instructions for STM32 MCU and hxd019 Chip0. Set three IOs and initialize:

 

Clarify the requirement before choosing a chip

Tell us the device type, interaction needs and volume plan; we will match a solution and arrange samples.

You are visitor No.7598   粤ICP备13027018号 Shenzhen Market Supervision Administration