linux io模拟时序,stm32用IO模拟8080时序,无法正确读取原子4.3寸屏的ID.

[mw_shl_code=c,true]//IO配置代码

GPIO_InitTypeDef GPIO_InitStructure;

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC,ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //推挽输出,GPIOD应该是作为并行数据线

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;

GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_SetBits(GPIOC,GPIO_Pin_All);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //推挽输出,

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd= GPIO_PuPd_UP;

GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_SetBits(GPIOB, GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14); //

LCD_RES_SET;

delay_ms(1);

LCD_RES_CLR;

delay_ms(200);

LCD_RES_SET;

delay_ms(200);

//读取ID

lcd_writecmd(0XDA00);

id=lcd_readdata();//读回0X00

printf("%x\n",id);

lcd_writecmd(0XDB00);

id=lcd_readdata();//读回0X80

id<<=8;

printf("%x\n",id);

lcd_writecmd(0XDC00);

id|=lcd_readdata();

printf("ID IS:");

printf("%x\n",id);[/mw_shl_code]

[mw_shl_code=c,true]//命令的读写

void lcd_writecmd(u16 reg)

{

LCD_RD_SET;

LCD_RS_CLR;//命令

LCD_CS_CLR; //片选选中

//delay_us(1);

LCD_WR_CLR; //写使能

DATAOUT(reg); //载入数据

reg=reg;

LCD_WR_SET;//写除能

LCD_CS_SET;//取消片选

}

uint16_t lcd_readdata()

{

uint16_t test=0X00;

GPIOC->MODER=0x00;//将端口模式设置为输出

LCD_WR_SET;

LCD_RS_SET;//数据

LCD_CS_CLR; //片选选中

LCD_RD_CLR; //写使能

test=GPIOC->IDR; //载入数据

LCD_RD_SET;//写除能

LCD_CS_SET;//取消片选

GPIOC->MODER=0x55555555;//将端口模式重新设置为输出

return test;

}[/mw_shl_code]

在调试的过程中,发现写入数据时是正确的,但是读取到的ID并不正确,希望大神能够予以解答,OTL.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值