打印

LM3S811使用心得 之12864串行显示

[复制链接]
15615|105
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
nwx8899|  楼主 | 2011-11-17 21:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 nwx8899 于 2011-11-18 11:58 编辑

11.12接到21IC的EK-LM3S811 EVALUATION BOARD,非常开心,。非常感谢TI,感谢21IC,感谢这次活动的举办者。本人目前大三,在次之前只用51单片机做过东西,对于ARM来说,我是初学者,对于LM3S811来说那就更陌生了。当我打开光盘的时候我有点不知所措,但出于对ARM兴趣,对LM3S811的好奇,自己还是硬着头皮看下去,慢慢来吧!自己的硬件及编程基础薄弱,所以对于TI M3 – Stellaris的学习只能慢慢来,一步一个脚印吧,希望大家见谅,同时对于自己的错误部分,希望大家能够指正、交流学习!

第一步:从第一个例子开始吧!
首先安装驱动,安装光盘里的下载软件,顺承51的KEIL以及光盘中的LM Flash Programmer。然后找到MDK安装文件下(D:\Keil\ARM\Boards\Luminary\ek-lm3s811\blinky)自带的测试程序,把其中的2000改成20000后LED的闪烁变慢了。这一刻证明EK_LM3S811 BOARD 与我的电脑连起来了,第一步已经成功了。
第二步:找关于LM3S系列的资料,下载LM3S的中文资料,以及API函数的用法。论坛里有很多有用的资料,但个人觉得在电脑上看时间长了就不行了,还是推荐一本从图书馆借的书吧。

第三步:自己的第一个简单程序(关于12864液晶的串行显示)。
//包含头文件
#include "hw_ints.h"
#include "hw_memmap.h"
#include "hw_types.h"
#include "gpio.h"
#include "sysctl.h"
#include "cpu.h"
#include "interrupt.h"
#include "hw_timer.h"
#include "debug.h"
#ifndef uchar
#define uint unsigned int
#define uchar unsigned char
#endif
//定义接口

#define CS GPIO_PIN_3    //PD0 PWMO    PD1 PWM1

#define SID GPIO_PIN_2

#define SCLK GPIO_PIN_4



uchar image[]={

0x02,0x08,0x00,0x08,0x00,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0xD0,0x06,0x04,0x08,0x03,0x02,0x00,0x38,0x80,0x00,0x00,0x00,0x00,0x00,0x00,

      0x41,0x00,0x09,0x43,0x00,0x04,0xA1,0x80,0x41,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
      
      0x42,0x00,0x29,0x00,0x00,0x14,0x80,0x00,0x8E,0x00,0xE7,0x00,0x00,0x00,0x00,0x00,

      0x32,0x88,0x29,0x30,0x04,0x14,0x98,0x00,0x70,0x00,0x1C,0x80,0x00,0x00,0x00,0x00,

      0x0C,0x00,0x16,0x48,0x00,0x0B,0x24,0x00,0x20,0x00,0x08,0x60,0x00,0x00,0x00,0x00,

      0x00,0x20,0x4D,0x80,0x00,0x26,0xC0,0x00,0x40,0x00,0x08,0x10,0x00,0x00,0x00,0x00,

      0x40,0x20,0x00,0x10,0x00,0x00,0x08,0x00,0x4C,0x00,0x08,0x10,0x00,0x00,0x00,0x00,

      0x04,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x00,0x08,0x20,0x00,0x00,0x00,0x00,

      0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x08,0x09,0xC0,0x00,0x00,0x00,0x00,

      0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x40,0x00,0x00,0x00,0x00,

      0x25,0x3F,0xC3,0xFE,0x3F,0xE0,0x00,0x01,0x10,0x04,0x00,0x40,0x00,0x00,0x00,0x00,

      0xA4,0x08,0x40,0x20,0x00,0x41,0x80,0x01,0x10,0x00,0x00,0x20,0x00,0x00,0x00,0x00,

      0xA4,0xC8,0x47,0xFF,0x00,0x83,0xC0,0x01,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,

      0x59,0x28,0x40,0x20,0x03,0x03,0xC0,0x02,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,

      0x36,0x08,0x81,0xFC,0x02,0x03,0xC0,0x02,0xF0,0x40,0x10,0x20,0x00,0x00,0x00,0x00,

      0x00,0x44,0x81,0x24,0x02,0x01,0x80,0x05,0x0C,0x04,0x10,0x20,0x00,0x00,0x00,0x00,

      0x00,0x05,0x01,0xFC,0x02,0x01,0x80,0x05,0x42,0x00,0x14,0x40,0x00,0x00,0x00,0x00,

      0x00,0x02,0x01,0x24,0x02,0x00,0x00,0x05,0x51,0x00,0x1C,0x40,0x00,0x00,0x00,0x00,

      0x00,0x05,0x03,0xFE,0x02,0x01,0x80,0x04,0x91,0x03,0xC0,0x40,0x00,0x00,0x00,0x00,

      0x00,0x18,0xC0,0x20,0x02,0x01,0x80,0x04,0x61,0x00,0x00,0x40,0x00,0x00,0x00,0x00,

      0x02,0x60,0x37,0xFF,0x0E,0x00,0x00,0x04,0x1E,0x00,0x00,0x80,0x00,0x00,0x00,0x00,

      0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,

      0x40,0x7F,0xF4,0x0A,0x3B,0xF3,0xFE,0x01,0x01,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,

      0x38,0x05,0x02,0x0A,0x2A,0x90,0x04,0x00,0xC7,0xF8,0x02,0x00,0x00,0x00,0x00,0x00,

      0x04,0x3F,0xE2,0xFF,0x2A,0x90,0x08,0x00,0x70,0xF8,0x04,0x00,0x00,0x00,0x00,0x00,

      0x20,0x25,0x20,0x88,0x3A,0x90,0x30,0x00,0xC7,0x00,0x08,0x00,0x00,0x00,0x00,0x00,

      0x00,0x3F,0xE2,0xF9,0x2B,0xF0,0x20,0x01,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,

      0x00,0x04,0x02,0x89,0x2A,0x00,0x20,0x02,0x20,0x00,0x01,0x00,0x00,0x00,0x00,0x00,

      0x41,0x7F,0xF4,0xFA,0x3A,0x00,0x20,0x04,0x48,0x00,0x00,0x80,0x00,0x00,0x00,0x00,

      0x18,0x08,0x84,0xD4,0x2A,0x00,0x20,0x08,0x80,0x08,0x00,0x80,0x00,0x00,0x00,0x00,

      0x20,0x1D,0x05,0x75,0x2A,0x10,0x20,0x09,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,

      0x40,0x03,0x85,0x4B,0x4A,0x10,0x20,0x12,0x30,0x00,0x80,0x40,0x00,0x00,0x00,0x00,

      0x50,0x7C,0x62,0x11,0x5B,0xF0,0xE0,0x13,0x8F,0xC0,0x80,0x20,0x00,0x00,0x00,0x00,

      0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x78,0x3F,0x00,0x20,0x00,0x00,0x00,0x00,

      0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x03,0xC0,0x80,0x20,0x00,0x00,0x00,0x00,

      0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x00,0x0F,0x80,0x20,0x00,0x00,0x00,0x00,

      0x84,0x80,0x00,0x1C,0x08,0x0E,0x04,0x28,0x00,0x00,0x40,0x20,0x00,0x00,0x00,0x00,

      0x04,0x1C,0x08,0x22,0x00,0x11,0x00,0x18,0x00,0x00,0x20,0x20,0x00,0x00,0x00,0x00,

      0x02,0x22,0x00,0x21,0x00,0x10,0x80,0x08,0x00,0x00,0x20,0x20,0x00,0x00,0x00,0x00,

      0xA1,0xA1,0x00,0x24,0xE0,0x12,0x70,0x10,0x00,0x00,0x30,0x20,0x00,0x00,0x00,0x00,

      0x80,0x24,0xE0,0x18,0x10,0x0C,0x08,0x10,0x00,0x00,0x28,0x20,0x00,0x00,0x00,0x00,

      0x98,0x18,0x10,0x00,0x80,0x80,0x40,0x10,0x08,0x00,0x25,0xE0,0x00,0x00,0x00,0x00,

      0x24,0x00,0x81,0x00,0x00,0x80,0x00,0x1A,0x08,0x00,0x22,0x20,0x00,0x00,0x00,0x00,

      0xC1,0x00,0x00,0x00,0x00,0x00,0x00,0x1D,0x46,0x00,0x22,0xA0,0x00,0x00,0x00,0x00,

      0x08,0x00,0x00,0x01,0x04,0x00,0x82,0x0F,0x93,0x40,0x21,0x40,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00



}

void delay(uint t)

{


uint i,j;


for(i=0; i<t;  i++)

    for(j=0; j<10; j++);

}

//发送一个字节

/********************************************************************

* 名称 : sendbyte()

* 功能 : 按照液晶的串口通信协议,发送数据

* 输入 : zdata

* 输出 :

***********************************************************************/

void sendbyte(uchar zdata)

{


uint i;


for(i=0;i<8;i++)


{



if((zdata<<=i)&0x80)



{



GPIOPinWrite(GPIO_PORTD_BASE,SID,SID);





}



else



{



GPIOPinWrite(GPIO_PORTD_BASE,SID,~SID);



}





delay(1);


GPIOPinWrite(GPIO_PORTD_BASE,SCLK,SCLK);


GPIOPinWrite(GPIO_PORTD_BASE,SCLK,~SCLK);


   delay(1);




}

}

//写数据或命令

void write(uchar dat,uchar cmd)

{
uchar temp,com;


GPIOPinWrite(GPIO_PORTD_BASE,CS,CS)
;


delay(2);


if(cmd==0)


com=0xF8;


else


com=0xFA;


sendbyte(com);


temp=dat&0xf0;


sendbyte(temp);


temp=((dat&0XF0)<<4)&0xf0;


sendbyte(temp);


delay(20);


GPIOPinWrite(GPIO_PORTD_BASE,CS,~CS) ;

}

//设置坐标

void setxy(uchar x,uchar y)

{

switch(y)

{

case 0:write(0x80+x,0);break;

case 1:write(0x88+x,0);break;

case 2:write(0x90+x,0);break;

case 3:write(0x98+x,0);break;

default: break;

}






}

//写字串

void  writestr(uchar x,uchar y,uchar *str)

{

uchar lcdtemp;

setxy(x,y);

lcdtemp=*str;

while(lcdtemp!= 0)

{

write(lcdtemp,1);

lcdtemp=*(++str);

}

}

//画图

void photodisplay(uchar *bmp)      

{   

  uchar i,j;   

  write(0x34,0);        //写数据时,关闭图形显示   

  for(i=0;i<32;i++)   

  {   

    write(0x80+i,0);    //先写入水平坐标值   

    write(0x80,0);      //写入垂直坐标值   

    for(j=0;j<16;j++)   //再写入两个8位元的数据   

    write(*bmp++,1);      

    delay(1);   

  }   



  for(i=0;i<32;i++)   

  {   

    write(0x80+i,0);  

    write(0x88,0);   

    for(j=0;j<16;j++)   

    write(*bmp++,1);

    delay(1);   

  }   

  write(0x36,0);       //写完数据,开图形显示     

}   





//初始化液晶

/********************************************************************

* 名称 : lcdinit()

* 功能 : 初始化函数

* 输入 : cmdcode

* 输出 :

***********************************************************************/

void lcdinit()

{  



GPIOPinWrite(GPIO_PORTD_BASE,CS,CS)
;


delay(100);


write(0x30,0);


delay(50);


write(0x0c,0);


delay(50);


write(0x06,0);


delay(50);


write(0x01,0);


delay(50);

}

//主函数

int main()

{  
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN


|
SYSCTL_XTAL_6MHZ);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

GPIODirModeSet(GPIO_PORTD_BASE,CS|SID|SCLK,GPIO_DIR_MODE_OUT);   


delay(100);


lcdinit();


delay(100);


photodisplay(image) ;//显示图片


writestr(0,3,"感谢21 IC ! !");


while(1);



}





最后的效果:





     小结:以上就是本人对LM3S811入门的一些心得,望大家指点。谢谢。对于进一步的琢磨,只能随着时间慢慢来了。再次感谢二姨给我这次学习的机会。谢谢!!!

最后效果.jpg (91.99 KB )

最后效果.jpg

推荐的书.png (167.85 KB )

推荐的书.png
评分
参与人数 1威望 +1 收起 理由
414779421 + 1

相关帖子

沙发
nwx8899|  楼主 | 2011-11-17 22:01 | 只看该作者
图片没有显示,又无法再编辑了,所以又发了个帖子把图补上了。。。

使用特权

评论回复
板凳
nwx8899|  楼主 | 2011-11-17 22:05 | 只看该作者
地板
jyz0025338| | 2011-11-17 22:34 | 只看该作者
看到后面的显示效果了,不错,顶起

使用特权

评论回复
5
lixiaoxu2meng| | 2011-11-18 07:33 | 只看该作者
不错帮顶

使用特权

评论回复
6
nwx8899|  楼主 | 2011-11-18 11:43 | 只看该作者
嘿嘿 学习学习

使用特权

评论回复
7
nwx8899|  楼主 | 2011-11-18 11:52 | 只看该作者
图片终于传上去了:lol

使用特权

评论回复
8
liangpingyy| | 2011-11-18 17:25 | 只看该作者
显示效果不错,呵呵

使用特权

评论回复
9
ic开发者| | 2011-11-18 18:08 | 只看该作者
做的不错,很帅啊,值得参考

使用特权

评论回复
10
21小跑堂| | 2011-11-19 14:40 | 只看该作者
继续努力!冲刺一百美金哦!:lol

使用特权

评论回复
11
fq1110| | 2011-11-19 21:03 | 只看该作者
没硬件图纸,光软件能冲刺$100吗?

使用特权

评论回复
12
靠双手奋斗| | 2011-11-20 18:37 | 只看该作者
呵呵,还行啊

使用特权

评论回复
13
xwj| | 2011-11-23 08:17 | 只看该作者
帮顶~

这个Demo板我也收到了,还没空玩,惭愧ing...

使用特权

评论回复
14
weshiluwei6| | 2011-11-23 10:21 | 只看该作者
:victory::victory:

使用特权

评论回复
15
teet| | 2011-11-23 13:20 | 只看该作者
羡慕

使用特权

评论回复
16
dengdc| | 2011-11-23 21:24 | 只看该作者
好长好长。。。

使用特权

评论回复
17
outstanding| | 2011-11-24 16:07 | 只看该作者
呵呵。看看

使用特权

评论回复
18
TA| | 2011-11-25 12:26 | 只看该作者
楼主厉害啊 我们一定好好学习

使用特权

评论回复
19
414779421| | 2011-11-25 20:46 | 只看该作者
heheh

使用特权

评论回复
20
414779421| | 2011-11-25 21:07 | 只看该作者
本帖最后由 永远的不知 于 2011-12-31 22:14 编辑

初学者,还行

使用特权

评论回复
评分
参与人数 1威望 +1 收起 理由
nwx8899 + 1
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名: 宁静致远

61

主题

805

帖子

2

粉丝