我用的是STM32RBT6,用HT1622驱动段码液晶显示,编译通过,软件仿真时候看到波形,为什么就是不显示?
以下程序,请指教,我新手。
int main(void)
{
LCD_Init();
ht1622_init();
write1622(0x2A,0x00,0x04);
while (1)
{
write1622(0x2A,0x00,4);
};
}
//?¨硬件
#define HT_CS_1 GPIOC->BSRR=GPIO_Pin_11 //PC.11--(LCD)/CS
#define HT_CS_0 GPIOC->BRR =GPIO_Pin_11
#define HT_WR_1 GPIOB->BSRR=GPIO_Pin_10 //PB.10--(LCD)/WR
#define HT_WR_0 GPIOB->BRR =GPIO_Pin_10
#define HT_DATA_1 GPIOB->BSRR=GPIO_Pin_11 //PB.11--(LCD)DATA
#define HT_DATA_0 GPIOB->BRR =GPIO_Pin_11
//#define DATAOUT GPIOD->ODR //PD[0..7]--(LCD)D0~D7
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef uint
#define uint unsigned int
#endif
void ht1622_init(void)
{
command1622(SYSDIS,8);//sys off
command1622(SYSEN,8);//sys on
command1622(LCDOFF,8);
command1622(LCDON,8);
command1622(RC32K,8);//?????????÷?¤×÷
command1622(WDTDIS,8);
}
/*********************************************************************************
* HT1622 operate funtion
********************************************************************************/
/************************ HT1622 read ***********************************/
void read1622(char Raddress,char Rrampoint,char Rbytelength)
{
char i;
start();
send(0xC0,3);// 110 commend
send(Raddress,6);//add
for(i=0;i<Rbytelength;i++)
{
// *RramPoint = receive();
RramPoint++;
}
stop();
return;
}
/************************ HT1622 write **************************************/
void write1622(char Waddress,char WramPoint,char Wbytelength)
{
//char i;
start();
send(0xA0,3); //101
Waddress = Waddress <<2;
send(Waddress,6); //add
WramPoint = WramPoint <<4;
send(WramPoint,Wbytelength); //add
//send(WramPoint,Wbytelength);
//for(i=0;i<Wbytelength;i++)
//{
// send(WramPoint,8);
// WramPoint++;
//}
stop();
return;
}
/************************* Commend *****************************************/
void command1622(char CramPoint,char Cbytelength)
{
//char i;
start();
send(0x80,3);
send(CramPoint,Cbytelength);
//for(i=0;i<Cbytelength;i++)
//{
//send(CramPoint,8);
//send(0x01,1);
//CramPoint++;
//}
send(0x80,1);
stop();
}
/************************* HT1622???± ***************************************/
void delay1622(void)
{
unsigned char i;
for(i=0;i<1000;i++);
return;
}
/*********************** receive data **********************************/
/*unsigned char receive(void)
{
unsigned char i,readbuffer;
IO_DDR = IO_DDR0 & 0x7F;
IO_DDR = IO_DDR0 & 0x7F;
IO_DDR = IO_DDR0 & 0x7F;
for(i=0;i<8;i++)
{
RD=LOW
}
}*/
/*********************** send data to buffer **********************************/
void send(char writebuffer,char bitlength)
{
unsigned char i;
for(i = 0;i<bitlength;i++)
{
delay1622();
HT_WR_0;
delay1622();
if(writebuffer & 0x80) HT_DATA_1;
else HT_DATA_0;
writebuffer = writebuffer << 1;
delay1622();
HT_WR_1;
delay1622();
}
return;
}
/************************ LCD×?±????÷ **************************************/
void start(void)
{
HT_CS_1;
HT_WR_1;
HT_DATA_1;
delay1622();
delay1622();
HT_CS_0;
delay1622();
return;
}
/********************************************************************************/
void stop(void)
{
HT_CS_1;
HT_WR_1;
HT_DATA_1;
delay1622();
return;
}
void show_all(void)
{
char i;
start();
send(0xA0,3);
send(0,6);
for(i=0;i<64;i++)
{
send(0x00,4);
}
stop();
}
void LCD_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure; //?¨???á????
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC, ENABLE); //?ò??GPIOC?±??
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; //????P
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //????
GPIO_Init(GPIOC, &GPIO_InitStructure); //?????è??
//GPIO_SetBits(GPIOC, GPIO_Pin_4); // turn off
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
//GPIO_SetBits(GPIOB, GPIO_Pin_10 | GPIO_Pin_11); // turn off
}
//HT1622 ?????ê?¨??
/*****************************************************************/
#define SYSDIS 0X00 // ???????????÷??LCD????·??ú?÷
#define SYSEN 0X01 // ?ò???????????÷
#define LCDOFF 0X02 // ??LCD????
#define LCDON 0X03 // ?ò??LCD????
#define TIMEDIS 0x04 // ?????±?ù????
#define WDTDIS 0x05 // ????WDT???±±ê??????
#define TIMEREN 0x08 // ?????±?ù????
#define WDTEN 0x0D // ????WDT???±±ê??????
#define TONEOFF 0x0F // ??±??ù??????
#define CLRTIMER 0x05 // ?????±?ù·??ú?÷??????
#define CLRWDT 0x0F // ????WDT??????
#define RC32K 0x18 // ?????±??????????RC?????÷
#define EXT32K 0x1C // ?????±???????????±????
#define TONE4K 0x40 // ??????????????4kHz??
#define TONE2K 0x60 // ??????????????2kHz??
#define IRQDIS 0x80 // ????IRQ????
#define IRQEN 0x88 // ????IRQ????
|