This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CCS/LAUNCHXL-CC1312R1:具有 LAUNCHXL-CC1312R1的 GPS

Guru**** 1986165 points
Other Parts Discussed in Thread: LAUNCHXL-CC1312R1
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/820800/ccs-launchxl-cc1312r1-gps-with-launchxl-cc1312r1

器件型号:LAUNCHXL-CC1312R1

工具/软件:Code Composer Studio

我有一个 GPS 模块、他们提供了一个与  PIC16F877A 连接的示例程序。 如何将该程序移植到 LAUNCHXL-CC1312R1?

1
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18
19.
20.
21.
22.
23
24
25
26
27.
28.
29.
30
31.
32
33.
34
35.
36.
37.
38.
39.
40
41.
42.
43.
44.
45.
46.
47.
48
49
50
51.
52.
53.
54
55
56.
57.
58.
59.
60
61.
62.
63.
64
65
66
67
68
69
70
71.
72.
73.
74.
75
76.
77
78
79
80
81.
82.
83.
84
85.
86
87
88
89
90
91.
92
93
94
95
96
97
98
99
100
101.
102.
103.
104.
105.
106.
107.
108.
109.
110
111.
112
113
114
115
116
117
118
119
120
121.
122.
123.
124.
125.
126.
127.
128
129.
130
/
微控制器- PIC 16 F877A - 40引脚8位。                             
时钟频率为20MHz,周期为200纳秒
波特率-9600。只有输出消息–$GPRMC (特定于建议的最小值
GNSS 数据)。 纬度和经度值显示在序列中
检测器。       
秘书长的报告 /
 
#include
 
/
                              全局变量
秘书长的报告 /
 
unsigned char Gpsdata;            //用于传入的串行数据
unsigned int finish =0;            //表示消息结束
unsigned int pos_cnt=0;            //位置计数器
unsigned int lat_cnt=0;            //纬度数据计数器
unsigned int log_cnt=0;            //经度数据计数器
unsigned int flg    =0;            // GPS 标志
unsigned int com_cnt = 0;            //逗号计数器
unsigned char lat[20];            //纬度数组
unsigned char lG[20];              //经度数组
 
/   
                          函数定义
秘书长的报告 /
 
void UART_initiatization ();
void UART_String (const unsigned char *dat);
 
void main()
TRISC = 0x80;
UART_initiatization ();            // UART 初始化
GIE  = 1;                        // Globel 中断使能位
PEIE = 1;                        //外设中断使能位
while (1){
  while (finish!= 1);
  UART_String ("Latitude  :");    //将 GPS 数据打印到串行监视器
  UART_String (lat);
  UART_String ("\r\n");
  UART_String (“经度:”);
  UART_String (LG);
  UART_String ("\r\n");
  完成= 0;
  POS_cnt = 0;
 
/
函数    :中断 ISR()
说明:中断服务               
秘书长的报告 /
空中断 ISR()
    if (Rcif){
      Rcif = 0;
      Gpsdata = RCREG;
      FLG = 1;
      if (finish = 0){
      if (Gpsdata='$'&& pos_cnt =0)  //查找 GPRMC 标头
        POS_cnt = 1;
      if (Gpsdata='G'&& pos_cnt = 1)
        POS_cnt = 2;
      if (Gpsdata='P'&& pos_cnt =2)
        POS_cnt = 3;
      if (Gpsdata='R'&& pos_cnt =3)
        POS_cnt = 4;
      if (Gpsdata='M'& pos_cnt =4)
        POS_cnt = 5;
      if (Gpsdata='C'  &&  pos_cnt =5)
        POS_cnt = 6;
      if (pos_cnt=6    &&  Gpsdata =','){  //在消息中计算逗号
        com_cnt++;
        FLG = 0;
      }
 
      if (com_cnnt=3 && flg=1){
        Lat[lat_cnt+]]=  Gpsdata;        //纬度
        FLG = 0;
      }
 
      if (com_cnnt=5 && flg=1){
        lg[log_cnt++]=  Gpsdata;        //经度
        FLG = 0;
      }
 
      if (Gpsdata ='*'&& com_cnt >=5 && flg =1){
        Lat[lat_cnt]='\0';            // GPRMC 消息结束
        lg [log_cnt]  ='\0';
        Lat _cnt = 0;
        log_cnt = 0;
        FLG    = 0;
        完成  = 1;
        com_cnt = 0;
 
      }
    }
    }
 
/
函数    :USART_initiization)
说明:UART 基本初始化                 
秘书长的报告 /
void UART_initiatization ()
  TXEN  = 1;
  SYNC  = 0;
  BRGH  = 1;
  SPBRG  = 0x81;
  spen  = 1;
  CREN  = 1;
  RCIE  = 1;
  Rcif  = 0;
 
/
函数    :USART_String
说明:转换数据的字符串
秘书长的报告 /
空 UART_String (const unsigned char *dat)
    while (*dat!='0'){
    TXREG =*dat;
    while (TRMT!= 1);
      DAT++;
  }
x 出现错误。请重试或与管理员联系。