嵌入式软件设计第10次实验报告
学号:140201110 姓名:王涵
组别:第4组 实验地点:D19
一、实验目的:
1、了解GSM模块SIM900A的使用方法。
2、掌握使用串口发送AT命令驱动SIM900A的
方法。
二、实验内容:
1.使用AT命令进行模块测试,拨打固定电话。
2.编写程序利用触摸屏完成任意电话的呼叫。
三、实验过程描述及结果展示:
实验器材:STM32F407开发板、LCD显示屏
1、实验原理
SIM900A跳线帽连接方式:
长按PWR_KEY键后网络状态指示灯对应的状态:
2、常用AT指令_准备工作:
3、常用AT命令_拨打电话
4、程序代码
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "lcd.h"
#include "key.h"
#include "touch.h"
#include "text.h"
#include "w25qxx.h"
#include "malloc.h"
#include "ff.h"
#include "exfuns.h"
const u16 POINT_COLOR_TBL[OTT_MAX_TOUCH]={RED,GREEN,BLUE,BROWN,GRED};
unsigned char Dialling[12];
char number[20] = "";
u8 iscalling=0;
int i,j;
//
void sendtext(char *p){
while(*p!='\0'){
USART_SendData(USART3,*p);
delay_ms(50);
p++;
}
USART_SendData(USART3,0x0D);
delay_ms(50);
USART_SendData(USART3,0x0A);
}
//²¦ºÅ
void call(){
char text[40]="ATD";//¶¨ÒåÎı¾
strcat(text,number);
strcat(text,";");
// printf("%s",text);
sendtext(text);//·¢ËÍÎı¾
POINT_COLOR=YELLOW;
for(i=180;i<=300;i++)//bohao
for(j=690;j<=750;j++)
LCD_DrawPoint(i,j);
POINT_COLOR=BLUE;
Show_Str(215,710,300,150,"¹Ò¶Ï",24,1);
iscalling=1;
}
void hangup(){
char text[40]="ATH";
sendtext(text);
number[0]='\0';
POINT_COLOR=YELLOW;
for(i=180;i<=300;i++)//bohao
for(j=690;j<=750;j++)
LCD_DrawPoint(i,j);
POINT_COLOR=BLUE;
Show_Str(215,710,300,150,"²¦ºÅ",24,1);
iscalling=0;
POINT_COLOR=YELLOW;
for(i=200;i<=400;i++)
for(j=90;j<=140;j++)
LCD_DrawPoint(i,j);
}
int main(void)
{
int i,j;
delay_init(168); //³õʼ»¯ÑÓʱº¯Êý
uart_init(115200); //³õʼ»¯´®¿Ú²¨ÌØÂÊΪ115200
uart3_init(115200);
LCD_Init(); //LCD³õʼ»¯
tp_dev.init(); //´¥ÃþÆÁ³õʼ»¯
LCD_Clear(BLACK);
POINT_COLOR=YELLOW;//ÉèÖÃ×ÖÌåΪ»ÆÉ«
BACK_COLOR = BLACK;
POINT_COLOR=WHITE;
Show_Str(100,100,300,150,"ºÅÂëÇø£º",24,1);
//
POINT_COLOR=YELLOW;
for(i=200;i<=400;i++)
for(j=90;j<=140;j++)
LCD_DrawPoint(i,j);
//
for(i=210;i<=270;i++)//5
for(j=370;j<=430;j++)
LCD_DrawPoint(i,j);
for(i=210;i<=270;i++)//2
for(j=270;j<=330;j++)
LCD_DrawPoint(i,j);
for(i=210;i<=270;i++)//8
for(j=470;j<=530;j++)
LCD_DrawPoint(i,j);
for(i=110;i<=170;i++)//1
for(j=270;j<=330;j++)
LCD_DrawPoint(i,j);
for(i=310;i<=370;i++)//3
for(j=270;j<=330;j++)
LCD_DrawPoint(i,j);
for(i=110;i<=170;i++)//4
for(j=370;j<=430;j++)
LCD_DrawPoint(i,j);
for(i=310;i<=370;i++)//6
for(j=370;j<=430;j++)
LCD_DrawPoint(i,j);
for(i=110;i<=170;i++)//7
for(j=470;j<=530;j++)
LCD_DrawPoint(i,j);
for(i=310;i<=370;i++)//9
for(j=470;j<=530;j++)
LCD_DrawPoint(i,j);
for(i=110;i<=170;i++)//*
for(j=570;j<=630;j++)
LCD_DrawPoint(i,j);
for(i=210;i<=270;i++)//0
for(j=570;j<=630;j++)
LCD_DrawPoint(i,j);
for(i=310;i<=370;i++)//#
for(j=570;j<=630;j++)
LCD_DrawPoint(i,j);
for(i=180;i<=300;i++)//bohao
for(j=690;j<=750;j++)
LCD_DrawPoint(i,j);
POINT_COLOR=BLUE;
Show_Str(215,710,300,150,"²¦ºÅ",24,1);
BACK_COLOR = BLACK;
LCD_ShowString(135,290,200,100,24,"1");//1
LCD_ShowString(235,290,200,100,24,"2");//2
LCD_ShowString(335,290,200,100,24,"3");//3
LCD_ShowString(135,390,200,100,24,"4");//4
LCD_ShowString(235,390,200,100,24,"5");//5
LCD_ShowString(335,390,200,100,24,"6");//6
LCD_ShowString(135,490,200,100,24,"7");//7
LCD_ShowString(235,490,200,100,24,"8");//8
LCD_ShowString(335,490,200,100,24,"9");//9
LCD_ShowString(135,590,200,100,24,"*");//*
LCD_ShowString(235,590,200,100,24,"0");//0
LCD_ShowString(335,590,200,100,24,"#");//#
//ÊäºÅÂë
while(1){
POINT_COLOR=BLUE;
tp_dev.scan(0);//
if(tp_dev.x[0]>110&&tp_dev.y[0]>270&&tp_dev.x[0]<170&&tp_dev.y[0]<330){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"1");//Ìí¼ÓºÅÂë
LCD_ShowString(200,100,336,24,24,number);//ÏÔʾºÅÂë
}
if(tp_dev.x[0]>210&&tp_dev.y[0]>270&&tp_dev.x[0]<270&&tp_dev.y[0]<330){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"2");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>310&&tp_dev.y[0]>270&&tp_dev.x[0]<370&&tp_dev.y[0]<330){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"3");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>110&&tp_dev.y[0]>370&&tp_dev.x[0]<170&&tp_dev.y[0]<430){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"4");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>210&&tp_dev.y[0]>370&&tp_dev.x[0]<270&&tp_dev.y[0]<430){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"5");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>310&&tp_dev.y[0]>370&&tp_dev.x[0]<370&&tp_dev.y[0]<430){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"6");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>110&&tp_dev.y[0]>470&&tp_dev.x[0]<170&&tp_dev.y[0]<530){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"7");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>210&&tp_dev.y[0]>470&&tp_dev.x[0]<270&&tp_dev.y[0]<530){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"8");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>310&&tp_dev.y[0]>470&&tp_dev.x[0]<370&&tp_dev.y[0]<530){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"9");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>110&&tp_dev.y[0]>570&&tp_dev.x[0]<170&&tp_dev.y[0]<630){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"*");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>210&&tp_dev.y[0]>570&&tp_dev.x[0]<270&&tp_dev.y[0]<630){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"0");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>310&&tp_dev.y[0]>570&&tp_dev.x[0]<370&&tp_dev.y[0]<630){
while((tp_dev.sta & 0x80) == 0x80)
{tp_dev.scan(0);}
strcat(number,"#");
LCD_ShowString(200,100,336,24,24,number);
}
if(tp_dev.x[0]>180&&tp_dev.y[0]>690&&tp_dev.x[0]<300&&tp_dev.y[0]<750){
if(iscalling){
hangup();
}else{
call();
}
while(tp_dev.x[0]!=65535){tp_dev.scan(0);}
}
delay_ms(5);
tp_dev.x[0] = 0xFFFF;
tp_dev.y[0] = 0xFFFF;
}
}
四、总结及实验心得:
这次课学习的是嵌入式移动通信平台设计,了解了GSM模块STM900A的使用方法,还掌握了实用串口发送AT命令驱动STM900A的方法。还有一些常用AT指令的用法。还实现了使用AT命令进行模块测试,拨打电话。编写程序利用触摸板完成任意电话的呼叫完成的不是很好,只做出了触摸屏设计,没有实现拨打电话,感觉还需要再努力。