HT16K33数码管驱动

syy最近对数码管驱动很感兴趣,想用linux i2c驱动来控制HT16K33数码管芯片进而控制LED
大致思路为
linux i2c -> HT16K33芯片 -> 8-Segment led
1. I2C:I2C大家老生长谈,贴一张I2C时序图

2.HT16K33数码管驱动_第1张图片
3.我们再看一下HT16K33 cmd

#define     DISPLAY_ON_OFF              0x81
#define     DIMMING_SET_DEFAULT         0xEF
#define     DISPLAY_DATA_RAM_LENGTH     16 
#define     LED_7SEG_HT16K33_DEFAULT_I2C_ADDR   0x70

注:建议在激活LCD 显示功能之前清除所有RAM 数据以初始化显示存储器RAM。如果
在启用LCD 显示功能之前未初始化RAM 数据,那么在执行LCD ON 指令后LCD 将
可能导致不正确的显示效果。
4.代码部分就很好写了,贴出来单片机的程序参考

//------WDT clock source: fsub
//****************************************************

#include "include.h"

//****************************************************


//****************************************************
void main()
{
    unsigned char i;
    mcu_initial();
    ram_clr();
    //HT16 MCU initial
    delay_100ms();
    HT16_Command_Write_Operation(SYSTEM_ON);
    HT16_Command_Write_Operation(SET_INT_OUTPUT_LOW);
    HT16_Command_Write_Operation(DISPLAY_OFF);
    HT16_Command_Write_Operation(DIMMING_SET_DEFAULT);
    for(i=0;i
    {
        HT16_Byte_Write_Operation(i,0x00);
    }
    //It is strongly recommended that the key data RAM of address 0x40H~0x45H
    //should be read continuously and in one operation  
    HT16_Page_Read_Operation(KEY_DATA_RAM_START,KEY_DATA_RAM_LENGTH,GV_U8_HT16_Key_Data);
    HT16_Command_Write_Operation(SYSTEM_OFF);

    GV_U8_Bright_Set=DIMMING_SET_DEFAULT;
    GV_U8_DRow0=0x41;
    GV_U8_DRow1=0xff;
    GV_U8_DRow9=0x1e;

    _emi=1;

    while(1)
    {
        GCC_CLRWDT();
        if(bTB0_INT)
        {
            bTB0_INT=0;
            Key_Detect();
            Bright_Adjust();
            Music_Adjust();
            Track_Time_Display();
        }
        LED_Panel_Update();
    }
}

5.神器i2ctools
参考大神的博文,感谢!
https://blog.csdn.net/xukai871105/article/details/18234075
1.scan i2c busfile
i2cdetect -l
2.i2c device
i2cdetect -y 1
3.寄存器内容导出
i2cdump -y 1(i2c总线编号) 0x51(i2c slave address)
4.寄存器内容写入
i2cset -y 1 0x50 (设备地址) 0x00(存储器地址) 0x13

你可能感兴趣的:(串口)