我用的是火牛的开发板,单独的I2C都是调试通的,然后想加入LCD显示,奇怪的问题来了(也可能是很简单的问题,是我自己没想明白)
代码如下:
void Init_All_Periph(void)
{
RCC_Configuration();
GPIO_Configuration();
NVIC_Configuration();
USART1_Configuration();
ADC_Configuration();
USART1Write((u8*)"test
",sizeof("test
"));
I2C_EE_Init();
// Lcd_Configuration();
Lcd_Initialize();
// Lcd_Clear(RGB565CONVERT(0, 255, 255));
// Lcd_Clear(0x5040); //这里我不注释掉的话 下面的I2C写操作不会成功。但是我如果把这一句加到上面的Lcd_Initialize()里的最后,则I2C写操作正常。我把Lcd_Clear(0x5040)里面的一句GPIOE->ODR =data;单独拿出来放在这里也会导致I2C不正常。郁闷了!
更郁闷的是不注释掉Lcd_Clear(0x5040); 把I2C写操作后面一句读操作打开,程序也能正常运行!
哪位大牛知道其中的奥秘?请不吝赐教!感谢
}
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
u8 x=0;
u16 i;
u16 SensorTp;
uint8_t ee_buffer1[15] = {"abcdefghijklmn"};
uint8_t ee_buffer2[15] = {'2','5','9'};
Init_All_Periph();
printf("ee_buffer1 = %s
",ee_buffer1);
I2C_EE_BufferWrite(ee_buffer1, 3, 15); //I2C写操作
// I2C_EE_BufferRead(ee_buffer2, 0, 15); //I2C读操作
此帖出自
小平头技术问答
一周热门 更多>