硬件连接如下: PB7~PB0=D7~D0 PB8=A0 PB9=A1 PB10=WR PB11=RD PB12=CS1 ///////////////操作宏 #define 8254_PORT GPIOB #define 8254_A0 GPIOB_Pin_8 #define 8254_A1 GPIOB_Pin_9 #define 8254_WR GPIO_Pin_10 #define 8254_RD GPIO_Pin_11 #define 8254_CS1 GPIO_Pin_12 #define 8254_CS2 GPIO_Pin_13 #define Reset8254_RD GPIO_ResetBits(8254_PORT, 8254_RD) #define Set8254_RD GPIO_SetBits(8254_PORT,8254_RD) #define Reset8254_WR GPIO_ResetBits(8254_PORT, 8254_WR) #define Set8254_WR GPIO_SetBits(8254_PORT,8254_WR) #define Reset8254_CS1 GPIO_ResetBits(8254_PORT, 8254_CS1) #define Set8254_CS1 GPIO_SetBits(8254_PORT,8254_CS1) #define Reset8254_CS2 GPIO_ResetBits(8254_PORT, 8254_CS2) #define Set8254_CS2 GPIO_SetBits(8254_PORT,8254_CS2) #define Set8254_A0 GPIO_SetBits(8254_PORT, 8254_A0) #define Reset8254_A0 GPIO_ResetBits(8254_PORT, 8254_A0) #define Set8254_A1 GPIO_SetBits(8254_PORT, 8254_A1) #define Reset8254_A1 GPIO_ResetBits(8254_PORT,8254_A1) //////////将0xb0写入控制寄存器 Set8254_CS1; Set8254_A0; Set8254_A1;//写控制寄存器 Reset8254_CS1; GPIOB->ODR = GPIOB->ODR & 0xff00| 0xb0;//写0xb0 Reset8254_WR ; Set8254_WR ; Set8254_CS1 没有考虑延迟,大神看看这样做是否可行?
|