1、ARM嵌入式课程设计中南林业科技大学课程名称:ARM嵌入式课程设计学 院:计算机与信息工程学院专业班级:电子信息工程一班设计者: 学号: 一、课程设计题目及其要求: 3二、设计方案分析: 4三、参考文献: 5四、总体流程设计图: 5五、设计流程图如下 6六、生产控制软件 71、定时器 72、A/D转换 73、LCDYM12864I液晶显示模块 8七、小组体会 11八、附录 12一、课程设计题目及其要求:某化学反应过程的装置如下图,它由4个容器组成,容器之间用泵连接,以此进行化学反应。每个容器都有检测容器空和满的传感器,2#容器还有加热器和温度传感器,3#容器还有搅拌器。化学反应流程如下:按启动
2、按钮后,1#、2#容器分别用泵P1、P2抽入碱和聚合物,抽满后各自的传感器发出信号,P1、P2关闭。2#容器在P2启动后10s开始启动加热器,当2#容器中的聚合物加热到60时,温度传感器发出信号,关闭加热器。当加热器关闭后,P3和P4启动,分别将1#、2#容器中的溶液送到3#反应器中,同时启动搅拌器,当3#满或1#、2#空,则P3、P4停止,P3、P4停止后搅拌器继续搅拌60s后,P5启动将混合液抽到产品池4#容器,直到4#满或3#空。成品将用P6抽走。为了提高生产效率,如果4#池没有满,当P3关闭时P1启动;P4关闭时P2启动,使1#、2#与3#并行工作。当按下停止按钮后,应该完成一个完整的
3、生产流程,即把1#、2#容器中的反应物用完,把3#容器所有混合液抽空到4#池,最终1#、2#、3#池处于空状态,然后才停止所有工作。综合题目设计要求,由于只需要用程序来控制反应流程,因而P1、P2、P3、P4、P5、P6以及加热器、搅拌器都用LED灯来同等代替,LED亮则表示开启,灭则表示关闭。用按键来表示容器的传感器以及开始键,按键按下则表示容器已满,反之则没有满。二、设计方案分析:当该化学反应装置开始键S1按下时,LED1和LED2开始点亮,表明开始向容器1和容器2开始分别注入碱和聚合物。与此同时在通过定时器的10秒定时后工作容器2的加热器开始工作,当容器1和容器2满状态时,由各自的传感器
4、即按键S2和S3按下,表明容器已满,则P1和P2停止工作即LED1和LED2同时熄灭。在开始注入液体时容器2中相对应的代表加热器工作的LED3开始点亮,由于容器2内有温度传感器,因此可以通过A/D转换把对应的温度模拟量转换成数字量,如果温度超过60摄氏度, P3和P4代表的LED4和LED5开始点亮,搅拌器对应的LED6也开始工作即点亮。把容器1和容器2的液体装入容器3的反应池中。当容器3满之后,P3和P4停止工作,即LED4和LED5熄灭,通过定时器0定时60秒来控制搅拌器工作即LED6再点亮60秒。之后待反应充分后把液体装入容器4中即LED7点亮,P5工作。当容器4中液体装满即按键S5按下
5、时,使P6开始工作即LED8开始点亮,如果容器4中液体未满时,将返回到刚开始状态继续注入液体使得继续工作。三、参考文献:1)周立功主编,ARM嵌入式系统基础教程,北京航空航天大学出版社,2008.92)开发板电路图,Y1_LPC 229X_V30.pdf四、总体流程设计图:LED3和LED6控制的加热器和A/D转换器LED3熄灭五 、设计流程图如下 各个模块对应关系如下:LED1P1 按键S1装置开始键按键S5#4满传感器按键S3#2满传感器按键S4#3满传感器按键S2#1满传感器LED7P5LED2P2 LED3加热器LED4P3 LED5P4 LED6搅拌器 LED8P6六、生产控制软件:
6、1、定时器:定时器0和1初始化工作:T0TC=0;T1TC=0;T0PR=0;T1PR=0;T0MCR=0X03;T1MCR=0X03;T0MR0=Fpclk/5;T1MR0=Fpclk/5;VICIntSelect=VICIntSelect&(34;VICVectCntl0=0x20|4;VICVectCntl1=0x20|5;VICVectAddr0=(uinttimer0_isr;VICVectAddr1=(uinttimer1_isr;T0IR|=0x01;T1IR|=0x01;VICIntEnable|=(34;2、A/D转换:初始化工作程序如下:void ADC_Init( voi
7、d ADCR = ( 1 0 | / SEL = 1 ,选择通道0( ( Fpclk /1000000 - 1 8 | / CLKDIV = Fpclk / 1000000 - 1 ,即转换时钟为1MHz( 0 16 | / BURST = 0 ,软件控制转换操作( 0 17 | / CLKS = 0 ,使用11clock转换( 1 21 | / PDN = 1 , 正常工作模式(非掉电转换模式( 0 22 | / TEST1:0 = 00 ,正常工作模式(非测试模式( 0 27 ; / EDGE = 0 (CAP/MAT引脚下降沿触发ADC转换VICIntEnable&=(118; 3、LC
8、DYM12864I液晶显示模块:程序如下:void Lcd_Command_Left( U8 a while ( ( Lcd_Left_Status_Read & 0x80 = 0x80 ;/busy waitLcd_Left_Command_Write = a; /write command bytevoid Lcd_Command_Right( U8 a while ( ( Lcd_Right_Status_Read & 0x80 = 0x80 ;/busy waitLcd_Right_Command_Write = a; /write command bytevoid Lcd_Data_
9、Left_WR( U8 a while ( ( Lcd_Left_Status_Read & 0x80 = 0x80 ;/busy waitLcd_Left_Data_Write = a; /write data void Lcd_Data_Right_WR( U8 a while ( ( Lcd_Right_Status_Read & 0x80 = 0x80 ; /busy waitLcd_Right_Data_Write = a; /write datavoid Lcd_Clear( void U8 a, b;for ( a = 0; a 8; a+ /Clear RAM space of
10、 displayLcd_Command_Left( 0xb8 | a ; /Set row address of the left half in display area Lcd_Command_Right( 0xb8 | a ; /Set row address of the left half in display area Lcd_Command_Left( 0x40 ; /Set tier address of the left half in display area Lcd_Command_Right( 0x40 ; /Set tier address of the left h
11、alf in display area b = 64;while ( b Lcd_Data_Left_WR( 0x00 ; /Write 0 on the left half of display areaLcd_Data_Right_WR( 0x00 ; /Write 0 on the right half of display area.b = b - 1;void Lcd_Init( void int timeout=30000; /overtime controlLcd_Command_Left( 0xC0 ; /Set the start row address on the lef
12、t halfLcd_Command_Right( 0xC0 ; /Set the start row address on the right halfdoLcd_Command_Left( 0x3F ;timeout-;while ( ( Lcd_Left_Status_Read & 0x20 = 0x20 & (timeout!=0 ;/if display and overtiem is not,waittimeout=30000;doLcd_Command_Right( 0x3F ;/Open the left and right half of display area.timeou
13、t-;while ( ( Lcd_Right_Status_Read & 0x20 = 0x20 & (timeout!=0 ;/if display and overtiem is not,waitvoid Lcd_Display_s( U8* S,uint x,uint y U8 a, b; U32 c = 0;if(y8for ( a = 2*x; a 2*x+2; a+ Lcd_Command_Left( 0xb8 | a ;Lcd_Command_Left( 0x40+ 8*y ; for ( b = 0; b 8; b+ Lcd_Data_Left_WR( Sc ;c = c +
14、1;elsefor ( a = 2*x; a 2*x+2; a+ Lcd_Command_Right( 0xb8 | a ;Lcd_Command_Right( 0x40+8*(y-8 ;for ( b = 0; b 8; b+ Lcd_Data_Right_WR( Sc ;c = c + 1;void Lcd_Display_c( U8* S,uint x,uint y U8 a, b; U32 c = 0;if(y4for ( a = 2*x; a 2*x+2; a+ Lcd_Command_Left( 0xb8 | a ;Lcd_Command_Left( 0x40+ 16*y ; fo
15、r ( b = 0; b 16; b+ Lcd_Data_Left_WR( Sc ;c = c + 1;elsefor ( a = 2*x; a 2*x+2; a+ Lcd_Command_Right( 0xb8 | a ;Lcd_Command_Right( 0x40+16*(y-4 ;for ( b = 0; b 16; b+ Lcd_Data_Right_WR( Sc ;c = c + 1;void Lcd_YM12864_Init( void Lcd_Init(; /LCD InitLcd_Clear(; /Clear screen七、小组体会:对于大多数嵌入式初学者来说,要想学好嵌入
16、式,学习与ARM相关的知识是很有必要的,例如ARM接口技术,然后掌控ARM研发工具Keil,学会使用仿真器,写些接口方面的代码。其实,ARM的研发工具是初学者最应该花时间掌握的,这好比马车前进的轮子!这段时间大概需要2个月,因为ARM设计的东西太多了,开发工具也比一般的单片机复杂。 在学习ARM的初级阶段,购买一些相关书籍是少不了的,因为好的书籍一般都比较系统,这对于自己系统掌握ARM来说是很重要的。系统掌控好ARM接口知识后,接着再进行bootloader的学习,如uboot移植连同系统移植等,这时因为之前已有了ARM接口方面的知识,所以uboot学习及移植就会很快了。 关于bootload
17、er的学习,应该算是ARM里面初学者最难突破的环节,但是这又是必须的(个人认为),因为这是掌握ARM底层原理的最好方法! 接着我们能够再移植kernel、制作自己的文档系统。这些都做好后,嵌入式研发环境就搭好了。下面就能够学习Linux系统编程及Linux驱动研发了。接口的基础会帮助我们更容易的理解驱动原理。同时,我们能够选择一个kernel里已支持的且您比较熟悉的接口的驱动如RTC等,进行分析和学习,并尝试进行修改或照着自己编写。按照这样的流程下来能够少走少许弯路,迅速入门,并且以一个比较合理的流程进行学习。八、附录#include LPC2294.H#include def.h#inclu
18、de config.h#include LCD_YM12864I.h#define uint unsigned int#define uchar unsigned char#define pump1 0x00000004#define pump2 0x00000010#define pump3 0x00000020#define pump4 0x00000040#define pump5 0x10000000#define pump6 0x20000000#define jiare 0x40000000#define jiaoban 0x80000000#define open 0x00010
19、000#define close 0x00020000#define binf1 0x00040000#define bine1 0x00080000#define binf2 0x00100000#define bine2 0x00200000#define binf3 0x00400000#define bine3 0x40000000uint count=0,sec=0,ms=0,miao=0;uchar temp,e=0;uchar s32= 0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x
20、00,0x00,0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00, 0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00,0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00, 0x10,0x10,0x10,0xFF,0x10,0x10,0x50,0x20,0xD8,0x17,
21、0x10,0x10,0xF0,0x10,0x10,0x00,0x00,0x7F,0x21,0x21,0x21,0x7F,0x80,0x40,0x21,0x16,0x08,0x16,0x21,0x40,0x80,0x00, 0x00,0xFE,0x02,0x22,0xDA,0x06,0x10,0xD2,0x56,0x5A,0x53,0x5A,0x56,0xD2,0x10,0x00,0x00,0xFF,0x08,0x10,0x08,0x07,0x10,0x17,0x15,0x15,0xFD,0x15,0x15,0x17,0x10,0x00, ; uchar d16=0x00,0xE0,0x10,0
22、x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0
23、x00,0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0
24、x3F,0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,;void Lcd_Command_Left( U8 a while (
25、 ( Lcd_Left_Status_Read & 0x80 = 0x80 ;/busy waitLcd_Left_Command_Write = a; /write command bytevoid Lcd_Command_Right( U8 a while ( ( Lcd_Right_Status_Read & 0x80 = 0x80 ;/busy waitLcd_Right_Command_Write = a; /write command bytevoid Lcd_Data_Left_WR( U8 a while ( ( Lcd_Left_Status_Read & 0x80 = 0x
26、80 ;/busy waitLcd_Left_Data_Write = a; /write data void Lcd_Data_Right_WR( U8 a while ( ( Lcd_Right_Status_Read & 0x80 = 0x80 ; /busy waitLcd_Right_Data_Write = a; /write datavoid Lcd_Clear( void U8 a, b;for ( a = 0; a 8; a+ /Clear RAM space of displayLcd_Command_Left( 0xb8 | a ; /Set row address of
27、 the left half in display area Lcd_Command_Right( 0xb8 | a ; /Set row address of the left half in display area Lcd_Command_Left( 0x40 ; /Set tier address of the left half in display area Lcd_Command_Right( 0x40 ; /Set tier address of the left half in display area b = 64;while ( b Lcd_Data_Left_WR( 0
28、x00 ; /Write 0 on the left half of display areaLcd_Data_Right_WR( 0x00 ; /Write 0 on the right half of display area.b = b - 1;void Lcd_Init( void int timeout=30000; /overtime controlLcd_Command_Left( 0xC0 ; /Set the start row address on the left halfLcd_Command_Right( 0xC0 ; /Set the start row addre
29、ss on the right halfdoLcd_Command_Left( 0x3F ;timeout-;while ( ( Lcd_Left_Status_Read & 0x20 = 0x20 & (timeout!=0 ;/if display and overtiem is not,waittimeout=30000;doLcd_Command_Right( 0x3F ;/Open the left and right half of display area.timeout-;while ( ( Lcd_Right_Status_Read & 0x20 = 0x20 & (time
30、out!=0 ;/if display and overtiem is not,waitvoid Lcd_Display_s( U8* S,uint x,uint y U8 a, b; U32 c = 0;if(y8for ( a = 2*x; a 2*x+2; a+ Lcd_Command_Left( 0xb8 | a ;Lcd_Command_Left( 0x40+ 8*y ; for ( b = 0; b 8; b+ Lcd_Data_Left_WR( Sc ;c = c + 1;elsefor ( a = 2*x; a 2*x+2; a+ Lcd_Command_Right( 0xb8 | a ;Lcd_Command_Right( 0x
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1