广告

原创 SPCE061A的12864驱动程序

2008-9-25 11:49 2318 0 1 分类: MCU/ 嵌入式

#include "spce061a.h"


const unsigned char bmp3[]={0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x05,0xAE,0x90,0x00,0x00,0x00,0x00,0x00,
      0x95,0x55,0x48,0x80,0x00,0x00,0x00,0x00,
      0x2B,0x55,0x00,0x00,0x00,0x00,0x00,0x00,
      0xA8,0x00,0x22,0x15,0x20,0x00,0x00,0x00,
      0x97,0xFB,0x00,0x00,0x00,0x00,0x00,0x00,
      0x45,0x55,0x08,0xA0,0x00,0x00,0x00,0x0A,
      0x6F,0xF4,0x00,0x00,0x00,0x00,0x00,0x00,
      0xB2,0x80,0x40,0x00,0x04,0x40,0x00,0x00,
      0xBA,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
      0x4D,0x55,0x15,0x15,0x20,0x00,0x00,0x95,
      0xD5,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xFF,0xE8,0x40,0x40,0x00,0x00,0x00,0x4A,
      0xAA,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
      0xFF,0xFF,0x2A,0x00,0x40,0x00,0x00,0x15,
      0x54,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xFF,0xFD,0xD0,0xAA,0x01,0x00,0x00,0x25,
      0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
      0xFF,0xFF,0xB6,0x00,0x10,0x00,0x01,0x4A,
      0x49,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xFF,0xFF,0xFD,0xE8,0x40,0x00,0x00,0x11,
      0x00,0x24,0x84,0x00,0x00,0x00,0x00,0x00,
      0xAB,0xFF,0xFF,0x55,0x00,0x00,0x00,0x24,
      0x02,0x49,0x5E,0xA0,0x00,0x00,0x00,0x00,
      0x84,0xBF,0xFF,0xF4,0x88,0x00,0x00,0x00,
      0x10,0x05,0xFF,0xF4,0x00,0x00,0x00,0x00,
      0x29,0x0B,0xFF,0xFA,0x20,0x00,0x00,0x00,
      0x02,0xBF,0xFF,0xFC,0x00,0x00,0x00,0x00,
      0x44,0xA0,0x57,0xFD,0x80,0x00,0x00,0x00,
      0x08,0x5F,0xFF,0xFF,0x80,0x00,0x00,0x00,
      0x91,0x0A,0xAA,0xF6,0x50,0x00,0x00,0x00,
      0x41,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,
      0x44,0xA0,0x01,0x1B,0x84,0x00,0x00,0x00,
      0x26,0xFF,0xFF,0xFF,0x90,0x00,0x00,0x00,
      0x11,0x0A,0xAA,0x6D,0x68,0x00,0x00,0x00,
      0x0B,0xFB,0xFF,0xEF,0xE0,0x00,0x00,0x00,
      0xC4,0xA0,0x01,0x02,0x80,0x00,0x00,0x00,
      0x43,0xF1,0xFE,0x63,0xF0,0x00,0x00,0x00,
      0x15,0x55,0x54,0x55,0x6A,0x00,0x00,0x00,
      0x9F,0xE3,0xFC,0x87,0x38,0x00,0x00,0x00,
      0xCA,0xAB,0x91,0x00,0x90,0x00,0x00,0x00,
      0x07,0xC1,0xFA,0x2A,0x80,0x00,0x00,0x00,
      0x25,0xFF,0xFE,0x95,0x2A,0x00,0x00,0x00,
      0x2F,0x13,0xFE,0xFC,0x10,0x00,0x00,0x00,
      0x95,0xFF,0xFF,0xC0,0x50,0x00,0x00,0x00,
      0x0F,0x41,0xFF,0xF3,0x80,0x00,0x00,0x00,
      0x4F,0xFF,0xFF,0xF9,0x2A,0x00,0x00,0x00,
      0x9F,0x08,0xFF,0xD4,0x00,0x00,0x00,0x00,
      0xB3,0xFF,0xFF,0xFE,0x54,0x80,0x00,0x00,
      0x1E,0xA0,0x7F,0xA0,0x00,0x00,0x00,0x00,
      0x5F,0xFE,0x7F,0xFE,0xAA,0x00,0x00,0x00,
      0x5F,0x57,0xFE,0x00,0x00,0x00,0x00,0x00,
      0xAF,0xFD,0x7F,0xFF,0x94,0x80,0x00,0x00,
      0x1F,0xFE,0xE8,0x00,0x00,0x00,0x00,0x00,
      0x7F,0xFA,0x7F,0x5F,0xCA,0x00,0x00,0x00,
      0x3F,0x55,0x00,0x00,0x00,0x00,0x00,0x00,
      0xAF,0xF1,0x7F,0xDE,0xF5,0x40,0x00,0x00,
      0x1A,0xA0,0x80,0x00,0x00,0x00,0x00,0x00,
      0xDF,0xF2,0x3F,0xFC,0xC2,0x00,0x00,0x00,
      0x50,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
      0x2F,0xFA,0xBF,0xFF,0xF4,0xA0,0x00,0x00,
      0x05,0x42,0x00,0x00,0x00,0x00,0x00,0x00,
      0x97,0xFE,0x3F,0xFF,0xE3,0x00,0x00,0x00,
      0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x68,0xFF,0xDF,0xD5,0x78,0x40,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x07,0x5F,0xFF,0x48,0x02,0x80,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xD0,0xAA,0xF4,0xA0,0xAA,0x40,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x0A,0x45,0x09,0x05,0x11,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xA1,0x28,0xA0,0x00,0x44,0x40,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x08,0x42,0x04,0x52,0x12,0x80,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xA5,0x09,0x51,0x00,0x48,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x50,0x04,0x4A,0x12,0x80,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xAA,0x05,0x50,0x21,0x48,0x20,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x90,0x02,0x84,0x12,0x80,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xD4,0x05,0x48,0x10,0x48,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x81,0x20,0x00,0x02,0x02,0x80,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xA4,0x84,0x92,0x48,0x94,0x40,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x48,0x10,0x00,0x00,0x21,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
     


main()
{Init_IO();
lcdreset();
while(1)
{lcdreset();
Full_Screen("黄河远上白去间,一片孤城万仞山。羌笛无须怨杨柳,春风不度玉门关。");
lcdwc(0x01);
delayns(5000,100);
       Disp_img(bmp3);
   delayns(5000,100);
   lcdwc(0x01);
   delayns(50,10);
  
}

;}


void Disp_img(unsigned char *img) //图形方式12864显示字模221 横向取模
{
unsigned char i,j;
unsigned int k = 0;
lcdwc(0x36); //图形方式
for(i=0;i<32;i++) //上半屏显示
   {lcdwc(0x80+i); //Y的坐标;
    lcdwc(0x80);   //X的坐标
    *P_Watchdog_Clear=0x1;
    for(j=0;j<16;j++)
     {    lcdwd(img[k++]);
       *P_Watchdog_Clear=0x1;
      }
    }


for(i=0;i<32;i++) //下半屏显示
   { lcdwc(0x80+i); //Y的坐标;
     lcdwc(0x88); //X的坐标
     *P_Watchdog_Clear=0x1;
for(j=0;j<16;j++)
       {lcdwd(img[k++]);
*P_Watchdog_Clear=0x1;
        }
    }
}


void Init_IO()//设置IOB口为输出口
{ *P_IOB_Dir=0xffff;
*P_IOB_Attrib=0xffff;
}


void delayns(int aa,int bb)
{int i,j;
for(i=0;i<aa;i++)
   for(j=0;j<bb;j++)
*P_Watchdog_Clear=0x0001;
}


void delay()
{int i,j;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
;
}


void lcdreset()
{ delayns(20,20);
   lcdwc(0x30);       //选择基本指令集
   lcdwc(0x30);       //选择8bit数据流
   delay();
   lcdwc(0x0c);       //开显示(无游标、不反白)
   delay(5);
   lcdwc(0x01);       //清除显示,并且设定地址指针为00H
   delay(5);
   lcdwc(0x06);       //指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位
}


void Set_Addr(unsigned int addr)//设定DDRAM的地址。
{delayns(10,10);
*P_IOB_Data=0x0180+addr;
delay();
*P_IOB_Data&=0xfeff;
delay();
}


int Read_Addr()//读取DDRAM地址
{int addr;
delayns(10,10);
*P_IOB_Dir=0xff00;
*P_IOB_Attrib=0xff00;
*P_IOB_Data=0x03ff;
delay();
*P_IOB_Data&=0xfeff;
delay(20,20);
addr=(*P_IOB_Data)&0x001f;
return addr;
}


void Write_Data(unsigned char *str)//写数据到DDRAM
{delayns(5,5);
Init_IO();
while(*str!='\0')
{ //Init_IO();
   *P_IOB_Data=0x0500+*str++;
   delay();
   *P_IOB_Data&=0xfeff;
     delay();
    }
   *str=0;
   *P_Watchdog_Clear=0x1;
}

void Full_Screen(unsigned char *str)
{int count="0";
delayns(5,5);
Init_IO();
while(*str!='\0')
{*P_IOB_Data=0x0500+*str++;
delay();
*P_IOB_Data&=0xfeff;
delay();
count++;
     if(count==16)
    Set_Addr(0x10);
     if(count==32)
     Set_Addr(0x0008);
     if(count==48)
     { Set_Addr(0x0018);
       count="0";}}
*str=0;
*P_Watchdog_Clear=0x1;
}


void lcdwc(unsigned int com)
{delayns(5,5);
*P_IOB_Data=0x0100+com;
delay();
*P_IOB_Data&=0xfeff;
delay();
}


void lcdwd(unsigned int data)
{ delayns(5,5);
*P_IOB_Data=0x0500+data;
delay();
*P_IOB_Data&=0xfeff;
delay();
}


广告

文章评论 1条评论)

登录后参与讨论

qinhld 2008-10-4 20:49

hao
相关推荐阅读
qingsha1314 2009-03-23 22:46
对某网友的不理解解释一下(12864坐标问题)
你可以看一下12864的资料,因为在每次写入地址并写好数据后,地址是自动加一的,也就是X坐标每次自动加一,所以,大循环里每次改变Y坐标,X坐标是在小循环里自动加的。因此只要每次把X的初始坐标一给即可。...
qingsha1314 2008-10-26 21:01
找工作好难,而某些公司的做法更让人可气
        今天又像以往跑出去找工作了,到了一个比较牛的大学去了,经过一个多小时的宣讲会,开始投简历,然后完了是等两个小时看通知有没有笔试机会,在操场上闲聊了两个小时 ,然后跑去看结果,我靠,居然...
qingsha1314 2008-10-09 23:55
AT24C04调试成功
经过一天的努力,终于把AT24C02 的驱动程序给搞定了。真是不容易,这个东西不是很好弄,而且时序的把握要非常好,稍有差迟,就不行了,现在把原程序传上来。89S52驱动+LCD1602显示。解压密码:...
qingsha1314 2008-09-16 14:44
VHDL写的鼠标驱动器+VGA显示
这是我们假期参加ALTERA电子竞赛时用的鼠标驱动器的VHDL代码.已经过测试成功.以下是源代码.无需修改就可以使用.library IEEE;use IEEE.STD_LOGIC_1164.ALL;...
qingsha1314 2008-07-11 11:28
大三的生活结束了
今天是考完试的最后一天,这也就意味着我的大三生活结束了.回顾这一学期的所做所为,感觉没有虚度,先后制作了好多小电子玩艺,也学到了一些东西.马上就要开始ALTERA的SOPC竞赛了,打算好好准备,争取拿...
我要评论
1
0
广告
关闭 热点推荐上一条 /3 下一条