数字频率计的设计_电子系统设计综合实验设计报告(编辑修改稿)内容摘要:

char define uint unsigned int define CS_0 P2OUT amp。 = ~BIT0 //片选为低电平 define CS_1 P2OUT |= BIT0 //片选为高电平 单片机课程设计 13 define SID_0 P2OUT amp。 = ~BIT1 //串行数据输入为 0 define SID_1 P2OUT |= BIT1 //串行数据输入为 1 define SCLK_0 P2OUT amp。 = ~BIT2 //时钟线拉低 define SCLK_1 P2OUT |= BIT2 //时钟线拉高 define PSB_0 P2OUT amp。 = ~BIT3 //出行输入 define LCD_DIR_OUT P2DIR |= BIT0 + BIT1 + BIT2 + BIT3 //4个端口设置为输出 /******************************************************************** * 名称 : SendByte * 功能 : 发送数据 * 输入 : Dbyte * 输出 : 无 ***********************************************************************/ void SendByte(uchar Dbyte) { uchar i。 LCD_DIR_OUT。 for(i = 0。 i 8。 i++) { if((Dbyte i) amp。 0x80) { SID_1。 } else { SID_0。 } SCLK_0。 _delay_cycles(2)。 SCLK_1。 } } /******************************************************************** * 名称 : Write_Instruction * 功能 : 向 LCD写指令 * 输入 : data * 输出 : 无 ***********************************************************************/ void Write_Instruction(uchar data) { LCD_DIR_OUT。 CS_1。 单片机课程设计 14 SendByte(0xf8)。 SendByte(data amp。 0xf0)。 SendByte((data 4) amp。 0xf0)。 _delay_cycles(20)。 } /******************************************************************** * 名称 : Write_Data * 功能 :向 LCD写入数据 * 输入 : data * 输出 : 无 ***********************************************************************/ void Write_Data(uchar data) { LCD_DIR_OUT。 CS_1。 SendByte(0xfa)。 SendByte(data amp。 0xf0)。 SendByte((data 4) amp。 0xf0)。 _delay_cycles(20)。 } /******************************************************************** * 名称 : LCD12864_Delay() * 功能 : 初始化 LCD12864 * 输入 : 无 * 输出 : 无 ***********************************************************************/ void LCD_Init() { LCD_DIR_OUT。 //设置输入方向为输出 PSB_0。 //LCD为串行输入方式 Write_Instruction(0x30)。 //基本指令集 _delay_cycles(10000)。 Write_Instruction(0x02)。 //地址归位 _delay_cycles(10000)。 Write_Instruction(0x0c)。 //整体显示打开 ,游标关闭 _delay_cycles(10000)。 Write_Instruction(0x01)。 //清除显示 _delay_cycles(10000)。 Write_Instruction(0x06)。 //游标右移 _delay_cycles(10000)。 Write_Instruction(0x80)。 //设定显示的起始地址 _delay_cycles(10000)。 单片机课程设计 15 } /******************************************************************** * 名称 : Write_Pos * 功能 : 确定输入数据的位置 * 输入 : x,y * 输出 : 无 ***********************************************************************/ void Write_Pos(uchar x,uchar y) { uchar pos。 if(x == 1) //第一行显示 x = 0x80。 else if(x == 2) //第二行显示 x = 0x90。 else if(x == 3) //第三行显示。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。