• 嵌入式软件设计第10次实验报告


    学号:142021209               姓名:田博文

    组别:第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!=''){

                  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]='';

          

           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模块SIM900A的使用方法,使用串口发送AT命令驱动SIM900A的方法,虽然实现功能的代码不是很熟悉,但是在其它组同学的帮助下还是完成了第一个实验,第二个实验只做了一半,虽然没做出来,但是我还是很高兴的,学到了很多。

  • 相关阅读:
    【1】排行榜算法设计
    基础问答【二】
    基础问答【一】
    【1】c语言
    (五)帧同步与状态同步
    (四)c++虚函数详解
    (三)git pull报错解决方案,Your local changes to the following files would be overwritten by merge
    (二)干货!获取该目录下,指定权限不为770的文件, 并设置权限为770
    【8】java新特性,双冒号 :: 的使用场景
    go(01) 基础语法
  • 原文地址:https://www.cnblogs.com/xzj0828/p/6624706.html
Copyright © 2020-2023  润新知