MCU用STC404AS,驱动是TM1638,看不懂他的规格书,请教大家帮忙,附上规格书:TM1638_V1.1.pdf
看那个表格描述是00H单元对应SEG1的是吗,然后SEG2是对应哪个单元?...明天我把我的原理图画出来,用过这类芯片的应该很清楚了帮忙解惑,第一次用这个摸不着头脑...
MCU用STC404AS,驱动是TM1638,看不懂他的规格书,请教大家帮忙,附上规格书:TM1638_V1.1.pdf
看那个表格描述是00H单元对应SEG1的是吗,然后SEG2是对应哪个单元?...明天我把我的原理图画出来,用过这类芯片的应该很清楚了帮忙解惑,第一次用这个摸不着头脑...
没人理,继续代码:人家的示例代码,就修改了显示代码,然后按键测试部分代码修改了也是没反应...
#include//MCU??? #include //??nop????? #define nop _nop_();_nop_();_nop_();_nop_();_nop_();_nop_(); //??? /********************??????**********************/ sbit DIO=P3^0; //??DIO sbit CLK=P3^1; //??CLK sbit STB=P3^2; //??STB /*********************** ???? ***********************/ unsigned char Key[5]={0}; //??????????? const unsigned char BCD_LABLE_ALL[]= {0xbb,0x88,0x6b,0xea,0xd8,0xf2,0xf3,0xa8,0xfd,0xea}; //{0xdd,0x11,0xd6,0x57,0x1b,0x4f,0xaf,0x15,0xdf,0x5f}; //{0xbf,0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff}; unsigned char BCD_LABLE_anode[16] = {0}; //?????????? TM1628????????? ??????? unsigned char cmd_dis_mode = 0x8f; /***************????**************/ void delay_nms(unsigned int n) { unsigned int i; while(n--) for(i=0;i<550;i++); } void delay_nus(unsigned int n) { unsigned int i; while(n--) for(i=0;i<50;i++); } /***************??8bit??,?????**************/ void send_8bit(unsigned char dat) { unsigned char i; for(i=0;i<8;i++) { CLK=0; if(dat&0x01) DIO=1; else DIO=0; _nop_(); _nop_(); _nop_(); CLK=1; dat>>=1; } CLK=0; DIO=0; } /******************??????***********************/ void send_command(unsigned char word) { STB=1; _nop_(); STB=0; send_8bit(word); } void Write_String(unsigned char *p,unsigned char cnt) //cnt??14byte { unsigned char i; for(i=0;i 0) { if(cnt>8) { //myflag |= 0x01; cnt = cnt -9; for(i=1;i<16;i=i+2) { if(ydata&0x01 == 0x01) { BCD_LABLE_anode[i] |= (0x01< >1); } } else { cnt = cnt -1; for(i=0;i<16;i=i+2) { if((ydata&0x01) == 0x01) { BCD_LABLE_anode[i] |= (0x01< >1); } } } } /************************************************************************************ ??SEG1-SEG8 ????1-8????,????????: cnt1 :???cnt1????; number: ????????,?number=1 ????1; display(0,1): ????1???????0. BCD_LABLE_ALL[0]:??0x3f, ??????0,?????????????????????? ************************************************************************************/ void display(unsigned char number,unsigned char cnt1) { NE_C(BCD_LABLE_ALL[number],cnt1); //???? send_command(0x40); //??????:?????????1,?????? send_command(0xc0); //????????:?00H?? Write_String(BCD_LABLE_anode,16); //???? 16??? ??1629?????16??? STB=1; send_command(cmd_dis_mode); } void display_fixedadd(unsigned char number,unsigned char cnt1) { NE_C(BCD_LABLE_ALL[number],cnt1); send_command(0x44); //??????:???????????,?????? send_command(0xc2); send_8bit(0x00);//?02???00 STB=0; send_command(cmd_dis_mode); STB=0; } /****************????????*******************/ void read_key() { unsigned char i,j; send_command(0x42); DIO=1; //??DIO for(j=0;j<4;j++) { for(i=0;i<8;i++) { CLK=0; Key[j]=Key[j]>>1; CLK=1; if(DIO) Key[j]=Key[j]|0x80;//1000 0000 nop; } nop; nop; } CLK=0; DIO=0; STB=1; } void key_process() { /* if(Key[0]!=0x00) { if((Key[0]==0x08)){display(1,1);} //K0?SEG1????,???????1 if((Key[0]==0x04)){display(2,1);} //K1?SEG1????,???????2 } if(Key[1]!=0x00) { if((Key[1]==0x08)){display(3,1);} //K0?SEG3????,???????3 if((Key[1]==0x04)){display(4,1);} //K1?SEG3????,???????4 } */ if(Key[1]!=0x00) { if(Key[1]==0x01)display(0,1); if(Key[1]==0x02)display(0,2); if(Key[1]==0x03)display(0,3); } if(Key[2]!=0x00) { if(Key[2]==0x04)display(1,1); if(Key[2]==0x05)display(1,2); if(Key[2]==0x06)display(1,3); } if(Key[1]!=0x00) { if(Key[3]==0x07)display(2,1); if(Key[3]==0x08)display(2,2); if(Key[3]==0x09)display(2,3); } if(Key[4]!=0x10) { if(Key[4]==0x20)display(3,1); if(Key[4]==0x30)display(3,2); if(Key[4]==0x40)display(3,3); } if(Key[5]!=0x00) { if(Key[5]==0x60)display(4,1); if(Key[5]==0x70)display(4,2); if(Key[5]==0x80)display(4,3); } if(Key[6]!=0x00) { if(Key[6]==0x90)display(5,1); if(Key[6]==0xa0)display(5,2); if(Key[6]==0xb0)display(5,3); } if(Key[7]!=0x00) { if(Key[7]==0xc0)display(6,1); if(Key[7]==0xd0)display(6,2); if(Key[7]==0xe0)display(6,3); } if(Key[8]!=0x00) { if(Key[8]==0x0a)display(7,1); if(Key[8]==0x0b)display(7,2); if(Key[8]==0x0c)display(7,3); } //if(Key[1]!=0x00){if((Key[1]==0x08)){display(2,1);}} //if(Key[2]!=0x00){if((Key[2]==0x08)){display(3,1);}} //if(Key[3]!=0x00){if((Key[3]==0x08)){display(4,2);}} // if(Key[4]!=0x00){if((Key[4]==0x08)){display(5,3);}} } void main() { char i; // //????????????? ?? 1 2 3 4 5 6 7 8 for(i=1;i<=3;i++){display(i%10,i);}delay_nms(5); //display(5,1); // display(6,2); // display(7,3); //??? while(1) { read_key(); key_process(); delay_nms(5); } }