ht1621驱动断码屏显示不正常

2019-01-02 21:39发布

问题:

  1 #include "lcd.h" 
  2 #include "sys.h"
  3 
  4 
  5 unsigned char tab2[]={ 
  6 0x00,0x00,0x00,0x00,0x00,0x0c,0x0b,0x0c,0x0b,0x00,0x0d,0x06,0x0d,0x06,0x0d,0x06, //5-20
  7 0x06,0x0b,0x06,0x0b,0x0d,0x06,0x0d,0x06,0x0d,0x06,0x0d,0x03,0x0d,0x06,0x0d,0x06,  //21-36
  8 0x0d,0x06,0x0d,0x06,0x0d,0x06,0x06,0x0b,0x06,0x0b,0x0d,0x06,0x0d,0x06,0x0d,0x06       //37-52
  9 };
 10 
 11 unsigned char tab9[]={
 12 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
 13 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
 14 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F
 15 };
 16 
 17 unsigned char tab5[]={
 18 0x00,0x00,0x00,0x00,0x00,0x06,0x0d,0x06,0x0d,0x00,0x0b,0x0c,0x0b,0x0c,0x0b,0x0c,
 19 0x03,0x0d,0x03,0x0d,0x0b,0x0c,0x0b,0x0c,0x0b,0x0c,0x0b,0x06,0x0b,0x0c,0x0b,0x0c,
 20 0x0b,0x0c,0x0b,0x0c,0x0b,0x0c,0x03,0x0d,0x03,0x0d,0x0b,0x0c,0x0b,0x0c,0x0b,0x0c
 21 };
 22 
 23 unsigned char tab8[]={
 24 0x00,0x00,0x00,0x00,0x00,0x0e,0x0f,0x0e,0x0f,0x00,0x0f,0x0e,0x0f,0x0e,0x0f,0x0e,  //5-20
 25 0x07,0x0f,0x07,0x0f,0x0f,0x0e,0x0f,0x0e,0x0f,0x0e,0x0f,0x07,0x0f,0x0e,0x0f,0x0e,  //21-36
 26 0x0f,0x0e,0x0f,0x0e,0x0f,0x0e,0x07,0x0f,0x07,0x0f,0x0f,0x0e,0x0f,0x0e,0x0f,0x0e     //37-52
 27 };
 28 
 29 unsigned char  tab0[]={
 30 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 31 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 32 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
 33 };
 34 
 35 unsigned char tab4[]={
 36 0x08,0x00,0x00,0x01,0x08,0x00,0x00,0x01,0x08,0x00,0x00,0x01,0x08,0x00,0x00,0x01,
 37 0x08,0x00,0x00,0x01,0x08,0x00,0x00,0x01,0x08,0x00,0x00,0x01,0x08,0x00,0x00,0x01,
 38 0x08,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
 39 };
 40 
 41 
 42 void Delayns(void)
 43 {
 44     __asm("nop");__asm("nop");__asm("nop");__asm("nop");__asm("nop");__asm("nop");__asm("nop");
 45     __asm("nop");__asm("nop");__asm("nop");__asm("nop");__asm("nop");__asm("nop");__asm("nop");
 46     __asm("nop");__asm("nop");__asm("nop");
 47 }
 48 
 49 void Delay_t(uint t)
 50 {
 51     uint i,j;
 52     for(i=0;i<t;i++)
 53     for(j=0;j<440;j++);
 54 }
 55 
 56 
 57 
 58 
 59 
 60 void Initial_LCD()
 61 {
 62     GPIO_InitTypeDef  GPIO_InitStructure;
 63     
 64     RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOB, ENABLE);
 65                                                    
 66     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4 |GPIO_Pin_5|GPIO_Pin_6;                 
 67     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; 
 68     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 69     GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
 70     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 
 71     GPIO_Init(GPIOB, &GPIO_InitStructure); 
 72     
 73     LCD_CS_H();
 74     LCD_WR_H();
 75     LCD_DATA_H();
 76     
 77     LCD_RD_L();
 78     delay_ms(10);
 79     LCD_RD_H();
 80     delay_ms(10);
 81     
 82 
 83     Write_command(0x30);//select 1/4 dut & 1/3 bias
 84     Write_command(0x02);//RC 256K
 85     Write_command(0x52);//system enable
 86     Write_command(0x06);//LCD ON
 87 }
 88 //////////////////////////////////////
 89 void Write_ID(unsigned char ID,unsigned char cnt)
 90 {
 91    unsigned char i;
 92    for(i=0;i<cnt;i++)
 93    {
 94        if((ID&0x80))
 95         LCD_DATA_H();
 96        else
 97         LCD_DATA_L();
 98        
 99        Delayns();
100        LCD_WR_L();
101        Delayns();
102        ID<<=1;
103        LCD_WR_H();
104    }
105  }
106  ////////////////////////////////////////
107 void Write_data_bit(unsigned char dat,unsigned char cnt)
108 {
109     unsigned char i;
110     for(i=0;i<cnt;i++)
111     {            
112         if((dat&0x01))//low bit start
113             LCD_DATA_H();
114         else
115             LCD_DATA_L(); 
116         
117         Delayns();
118         
119         LCD_WR_L();
120         Delayns();
121         dat>>=1;
122         LCD_WR_H();
123     }
124     //delay_ms(1);
125 }
126 //写命令函数
127 void Write_command(unsigned char Command_byte)
128 {
129     LCD_CS_L();
130     //delay_us(5);
131     Write_ID(0x80,3);
132     Write_ID(Command_byte,8);
133     
134     Delayns();
135     LCD_WR_L();
136     Delayns();        
137     LCD_WR_H();
138     
139     LCD_CS_H();
140 
141 }
142 
143 
144 ////////////////////////////////////////
145 void Singal_data_write(unsigned char address,unsigned char dat)
146 {
147     LCD_CS_L();
148     Write_ID(0xa0,3);   //write  101
149     Write_ID(address,6);//address from 0x00
150     Write_data_bit(dat,4);
151     LCD_CS_H();
152  
153 }
154 
155 
156 /*********************************************/
157 void Writeall_data_1621(unsigned char *p)
158 {
159     unsigned char i;
160     unsigned char temp_data;
161     LCD_CS_L();
162     Write_ID(0xa0,3);//write
163     Write_ID(0x00,6);//address from 0x00
164 
165     for(i=0;i<48;i++)
166     {
167     temp_data =p[i];
168     Write_data_bit(temp_data,4);
169     }
170     LCD_CS_H();
171 }

 

可以单独点亮某一个seg段,让全部断码显示时,com3上的段不显示,这是为什么呢

seg(48)*com(4)

回答1:

会不会是硬件问题?



标签: