10 黑幣
捕獲.PNG (46.37 KB, 下載次數: 67)
下載附件
仿真圖
2018-12-26 20:17 上傳
void GPIO_Configuration()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB , ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3
|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11| GPIO_Pin_10 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
void delay_us(unsigned long n)
{
unsigned long j;
while(n--)
{
j=8;
while(j--);
}
}
/*******************************************************************************
* Function Name : delay_nms
* Description : delay n ms
*******************************************************************************/
void delay_ms1(unsigned long n)
{
while(n--)
delay_us(1100);
}
void Write_Command_LCM(u8 com)
{
GPIO_ResetBits(GPIOA,GPIO_Pin_11);
GPIO_ResetBits(GPIOA,GPIO_Pin_12);
GPIO_Write(GPIOB, com);
GPIO_ResetBits(GPIOA,GPIO_Pin_10);
delay_ms1(5);
GPIO_SetBits(GPIOA,GPIO_Pin_10);
delay_ms1(5);
GPIO_ResetBits(GPIOA,GPIO_Pin_10);
}
void Write_Data_LCM(u8 info)
{
GPIO_ResetBits(GPIOA,GPIO_Pin_11);
GPIO_ResetBits(GPIOA,GPIO_Pin_10);
GPIO_Write(GPIOB, info);
GPIO_SetBits(GPIOA,GPIO_Pin_12);
delay_ms1(5);
GPIO_SetBits(GPIOA,GPIO_Pin_10);
delay_ms1(5);
GPIO_ResetBits(GPIOA,GPIO_Pin_10);
}
/*---------------------------------------------
oˉêyÃû£oLCM_Init()
1| Äü£o¶ÔLCD 16023õê¼»ˉ
----------------------------------------------*/
void LCM_Init(void)
{
Write_Command_LCM(0x38);
Write_Command_LCM(0x08);
Write_Command_LCM(0x06);
Write_Command_LCM(0x01);
Write_Command_LCM(0x0C);
}
void Set_xy_LCM(unsigned char x, unsigned char y)
{
unsigned char address;
if( x == 0 )
address = 0x80+y;
if( x == 1 )
address = 0xC0+y;
Write_Command_LCM(address);
}
void Display1(unsigned int x, unsigned int y, unsigned char *s)
{
Set_xy_LCM(x,y);
while(*s)
{
Write_Data_LCM(*s);
s++;
}
}
int main(void)
{
void GPIO_Configuration();
Display1(0, 0, "www*szopen*cn");
while(1);
}
我來回答
捕獲.PNG
(3.42 KB, 下載次數: 63)
下載附件
2018-12-26 20:15 上傳
主程序
LCD1602顯示.rar
2018-12-26 23:07 上傳
點擊文件名下載附件
264.09 KB, 下載次數: 11
程序