因为lcd的引脚和led的引脚是,复用引脚。官方给的LCD历程在操作时会影响到LED灯操作。要"lcd.c"里的三个函数里加入,两句寄存器操作的代码。防止 lcd 再和 led 打架。
void LCD_WriteReg(u8 LCD_Reg, u16 LCD_RegValue)
{
unsigned short PCOUT=GPIOC->ODR; //寄存器操作,防止操作LCD屏幕时,点亮led灯
GPIOB->BRR = 0x0200;
GPIOB->BRR = 0x0100;
GPIOB->BSRR = 0x0020;
GPIOC->ODR = LCD_Reg;
GPIOB->BRR = 0x0020;
GPIOB->BSRR = 0x0020;
GPIOB->BSRR = 0x0100;
GPIOC->ODR = LCD_RegValue;
GPIOB->BRR = 0x0020;
GPIOB->BSRR = 0x0020;
GPIOB->BSRR = 0x0100;
GPIOC->ODR =PCOUT ; //寄存器操作,防止操作LCD屏幕时,点亮led灯
}
void LCD_WriteRAM_Prepare(void)
{
unsigned short PCOUT = GPIOC->ODR ;
GPIOB->BRR = 0x0200;
GPIOB->BRR = 0x0100;
GPIOB->BSRR = 0x0020;
GPIOC->ODR = R34;
GPIOB->BRR = 0x0020;
GPIOB->BSRR = 0x0020;
GPIOB->BSRR = 0x0100;
GPIOB->BSRR = 0x0200;
GPIOC->ODR =PCOUT;
}
void LCD_WriteRAM(u16 RGB_Code)
{
unsigned short PCOUT = GPIOC->ODR ;
GPIOB->BRR = 0x0200;
GPIOB->BSRR = 0x0100;
GPIOB->BSRR = 0x0020;
GPIOC->ODR = RGB_Code;
GPIOB->BRR = 0x0020;
GPIOB->BSRR = 0x0020;
GPIOB->BSRR = 0x0100;
GPIOB->BSRR = 0x0200;
GPIOC->ODR =PCOUT;
}