完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include
#define uchar unsigned char #define uint unsigned int /* * main.c */ unsigned char tab[]={//图像数据 宽度x高度=128x64 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xC0,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x80,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xCF,0xFF, 0x80,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x80,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x80,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x80,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x80,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0x00,0x60,0xE1,0xFF,0xFF,0xFF,0xFF,0xFF, 0x80,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0x00,0x61,0xE1,0xFF,0xFF,0xFF,0xFF,0xFF, 0x80,0x04,0x00,0x00,0x00,0x00,0x03,0xFF,0x0C,0x60,0x00,0x3F,0xFF,0xFF,0xFF,0xFF, 0x80,0xFC,0x00,0x00,0x00,0x00,0x03,0xFF,0x0C,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xF7, 0x83,0xFF,0xC0,0x00,0x00,0x00,0x03,0xFF,0x0C,0x00,0xE1,0xFF,0xFF,0xFF,0xFF,0xF7, 0x8F,0xCF,0xC0,0x00,0x00,0x00,0x03,0xFF,0x0C,0x61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,0xFF,0xFF,0xE9,0x27,0x7D,0xC9,0xF2,0x07,0xFF,0xE0,0x2F, 0xF8,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF2,0xF3,0x3B,0x93,0xE3,0x03,0xFF,0xC0,0x6F, 0xF8,0x0F,0xFF,0xFF,0xFF,0xFE,0xFF,0xF2,0xE8,0x44,0xF2,0xA5,0x83,0xFF,0x20,0xDF, 0xF8,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0x4C,0xCE,0x79,0x0D,0x87,0x01,0xF1,0x7F, 0xE0,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x11,0x01,0x3E,0x37,0xE4,0xD8,0x22,0xFF, 0xF0,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x31,0x01,0x1F,0x05,0xF4,0x19,0x97,0xFF, 0xF0,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE2,0x45,0x9F,0xC3,0xF5,0x19,0x67,0xFF, 0xE0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xD2,0x00,0xBF,0xC7,0xFC,0x59,0x1B,0xFF, 0xE0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xD6,0x06,0xCF,0xFF,0xFC,0x59,0x3F,0xFF, 0xE0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEE,0x00,0xEF,0xFF,0xFD,0xD9,0xDB,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, }; /************************************************************************* 12864液晶串行显示测试程序 P7.4模拟SID(接第5脚),P2.2模拟SCLK(接第6脚) 4脚(CS信号)接高电平选通,15脚(PSB信号)接地选择串行方式->和GND焊盘相接 17脚(RST信号)根据注释提示悬空 *************************************************************************/ void int_port(void) //管脚初始化 { //P7.4模拟SID,设置为i/o口输出方向 P7DIR|=BIT4; P7OUT&=~BIT4; //P2.2模拟SCLK,设置为i/o口输出方向 P2DIR|=BIT2; P2OUT&=~BIT2; } /******************************************************************** * 名称 : delay() * * 输入 : t * 输出 : 无 ***********************************************************************/ void delay(uint t) //延时函数 { //粗略延时,满足时序要求 uint i,j; for(i=0; i } /******************************************************************** * 名称 : sendbyte() * 功能 : 按照液晶的串口通信协议,发送数据 * 输入 : zdata * 输出 : 无 ***********************************************************************/ void sendbyte(uchar zdata) //数据传送函数 { uchar code_seg7; uchar serial_clk; uchar serial_shift; code_seg7=zdata; serial_shift=0x80; for(serial_clk=0; serial_clk<8; serial_clk++) { if(code_seg7&serial_shift) { P7OUT|=BIT4; //SID为1 } else { P7OUT&=~BIT4; //SID为0 } P2OUT&=~BIT2; //产生时钟信号下沿 _NOP(); P2OUT|=BIT2; //产生时钟信号上沿 serial_shift=serial_shift>>1; //准备发送下一位数据 } } /******************************************************************** * 名称 : write_com() * 功能 : 写串口指令 * 输入 : cmdcode * 输出 : 无 ***********************************************************************/ void write_com(unsigned char cmdcode) //写命令函数 { //串口控制格式(11111AB0) //A数据方向控制,A=H时读,A=L时写 //B数据类型选择,B=H时为显示数据,B=L时为命令 sendbyte(0xf8); //MCU向LCD发命令 sendbyte(cmdcode & 0xf0); //发高四位数据(数据格式D7D6D5D4_0000) sendbyte((cmdcode << 4) & 0xf0);//发低四位数据(数据格式D3D2D1D0_0000) delay(4); //延时等待 } /******************************************************************** * 名称 : write_data() * 功能 : 写串口数据 * 输入 : Dispdata * 输出 : 无 ***********************************************************************/ void write_data(uchar Dispdata)//写数据函数 { sendbyte(0xfa); //MCU向LCD发数据 sendbyte(Dispdata & 0xf0); //发高四位数据 sendbyte((Dispdata << 4) & 0xf0);//发低四位数据 delay(4); } /******************************************************************** * 名称 : lcdinit() * 功能 : 初始化函数 * 输入 : cmdcode * 输出 : 无 ***********************************************************************/ void lcdinit() //LCD初始化 { delay(20000); //复位等待(内部自带上电复位电路),时间较长 write_com(0x36); //功能设定:基本指令集操作 delay(50); //延时等待 write_com(0x36); //功能设定:基本指令集操作 delay(50); //延时等待 write_com(0x3E); //整体显示,关游标 delay(50); write_com(0x01); //清屏 delay(50); write_com(0x06); //入口设置 delay(50); } void dispicture(uchar *addr) { uint i,j; for(i=0;i<32;i++) { write_com(0x80+i); write_com(0x80); for(j=0;j<16;j++) { write_data(*addr); addr++; } } for(i=0;i<32;i++) { write_com(0x80+i); write_com(0x88); for(j=0;j<16;j++) { write_data(*addr); addr++; } } } int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer int_port(); lcdinit(); dispicture(tab2); while(1); } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
3032个成员聚集在这个小组
加入小组2928 浏览 1 评论
MSP430FR5994 使用库函数 定时器触发AD问题请教
3600 浏览 2 评论
请问怎么把下面51单片机的代码改成msp430 g2 pocket的代码,还有改下时间变成30秒
2341 浏览 1 评论
4804 浏览 1 评论
2573 浏览 1 评论
1328浏览 3评论
MSP430FR5994 使用库函数 定时器触发AD问题请教
3600浏览 2评论
2928浏览 1评论
1510浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 03:44 , Processed in 1.079617 second(s), Total 70, Slave 53 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号