找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3812|回復(fù): 3
打印 上一主題 下一主題
收起左側(cè)

ht1621驅(qū)動斷碼屏。全顯時,com4上的段不顯示

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:289495 發(fā)表于 2018-11-8 09:42 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
10黑幣
測試發(fā)現(xiàn),點亮的斷碼越多,com4上的段顯示越暗,全部顯示后,com4上的段就沒顯示了
怎么回事啊?

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

來自 2#
ID:289495 發(fā)表于 2018-11-16 08:42 | 只看該作者
已解決,硬件問題
回復(fù)

使用道具 舉報

板凳
ID:289495 發(fā)表于 2018-11-15 11:20 | 只看該作者

本帖最后由 fsdSADASDSA 于 2018-11-15 11:15 編輯

這是程序

#include "lcd.h"
#include "sys.h"

unsigned char tab9[]={
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F
};
unsigned char tab0[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};



void Delayns(void)
{
        __asm("nop");__asm("nop");__asm("nop");__asm("nop");__asm("nop");__asm("nop");
        __asm("nop");__asm("nop");__asm("nop");__asm("nop");__asm("nop");__asm("nop");
}

void Delay_t(uint t)
{
        uint i,j;
        for(i=0;i<t;i++)
        for(j=0;j<80;j++);
}



//PB3--CS
//PB4--背光
//PB5--WR
//PB6--DATA

void Initial_LCD()
{
        GPIO_InitTypeDef  GPIO_InitStructure;

        RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOB, ENABLE);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4 |GPIO_Pin_5|GPIO_Pin_6;                 
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
        GPIO_Init(GPIOB, &GPIO_InitStructure);

        LCD_CS_H();
        LCD_WR_H();
        LCD_DATA_H();

        LCD_RD_L();
        delay_ms(10);
        LCD_RD_H();
        delay_ms(100);

        Write_command(0x30);//select 1/4 dut & 1/3 bias
        Write_command(0x02);//RC 256K
        Write_command(0x52);//system enable
        Write_command(0x06);//LCD ON
}
//////////////////////////////////////
void Write_ID(unsigned char ID,unsigned char cnt)
{
   unsigned char i;

   for(i=0;i<cnt;i++)
   {   
           LCD_WR_L();
           delay_us(5);
           if(ID&0x80)
                 LCD_DATA_H();
           else
                LCD_DATA_L();


           LCD_WR_H();
           delay_us(5);

           ID<<=1;
   }
}

void Write_data_bit(unsigned char dat,unsigned char cnt)
{
        unsigned char i;
        for(i=0;i<cnt;i++)
        {               
                LCD_WR_L();        
                delay_us(5);

                if(dat&0x01)
                        LCD_DATA_H();        
                else
                        LCD_DATA_L();

                //delay_us(5);
                LCD_WR_H();
                delay_us(5);
                dat>>=1;               
        }
}
//寫命令函數(shù)
void Write_command(unsigned char Command_byte)
{
        LCD_CS_L();
        delay_us(5);

        Write_ID(0x80,4);
        Write_ID(Command_byte,8);        
        LCD_CS_H();
}


//寫一個數(shù)據(jù)
void Singal_data_write(unsigned char address,unsigned char dat)
{
        LCD_CS_L();
        delay_us(5);

        Write_ID(0xa0,3);//write   101
        Write_ID(address,6);//address from 0x00
        Write_data_bit(dat,4);

        LCD_CS_H();delay_us(5);
}


//寫所有數(shù)據(jù)
void Writeall_data_1621(unsigned char *p)
{
        unsigned char i;
        unsigned char temp_data;
        LCD_CS_L();
        delay_us(5);

        Write_ID(0xa0,3);//write   101
        Write_ID(0x00,6);//address from 0x00

        for(i=0;i<48;i++)
        {
                temp_data =p;
                Write_data_bit(temp_data,4);
        }

        LCD_CS_H();
}

#include "sys.h"
#include "lcd.h"


extern unsigned char tab8[];
extern unsigned char tab2[];
extern unsigned char tab9[];
extern unsigned char tab5[];
extern unsigned char tab0[];
extern unsigned char tab4[];

int main(void)
{
        delay_init(48);

       Initial_LCD();

        delay_ms(1000);
        delay_ms(1000);
        Writeall_data_1621(tab0);   //清屏
        delay_ms(100);

        while(1)
        {
               Writeall_data_1621(tab9);                        Delay_t(3000);//全部顯示
        }
}

回復(fù)

使用道具 舉報

地板
ID:337808 發(fā)表于 2018-12-13 22:08 | 只看該作者
//寫所有數(shù)據(jù)
void Write_All_data_1621(unsigned char *p)
{
        unsigned char i;
        unsigned char temp_data;
        LCD_CS_L();
        delay_us(5);

        Write_ID(0xA0,3);//write   101
        Write_ID(0x00,6);//address from 0x00

        for(i=0;i<48;i++)
        {
                temp_data = p++;        //原文為temp_data=p; 請樓主賜教????
                Write_data_bit(temp_data,4);
        }

        LCD_CS_H();
}
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表