在C中编程GM862 [英] Programming GM862 in C

查看:78
本文介绍了在C中编程GM862的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我遇到麻烦,很难从telit编程GM862。

首先,我正在使用pic18f45k20,使用开发套件pickit3。

我一直在尝试使用UART与GM862进行通信(连接TX和RX),我在网上看到它相当简单等......但它对我不起作用..

我觉得问题是我的UART,我不知道怎么回事工作,我没有得到任何东西....

以下是我从供应商提供的样本中得到的代码...

如果有人可以真的帮助我!这是我毕业的最后一个项目!谢谢你...

Hello I''m having trouble, BIG trouble programing a GM862 from telit.
First of all I''m using pic18f45k20, using development kit pickit3.
I''ve been trying to communicate with the pickit to the GM862 using UART (connecting TX and RX), I read online that it is fairly simple etc.. but it doesn''t work for me..
I think the problem is my UART, I''m not sure how it works and I dont get any thing....
Below is the code I''m using deriving from the sample given from the vendor...
If someone can really help me on that! This is my final project to graduate! thank youuu...

展开 | 选择 | Wrap | 行号

推荐答案

首先我想说我有使用这两种产品没有问题。不可否认,我使用带有Semiens GSM模块的PIC和带有Cyan微处理器的Telit GSM模块。


您的代码中有许多问题并不好。它们可能会也可能不会引起问题。


首先,我假设您实际上已将PIC的TX引脚连接到Tellit的RX引脚,反之亦然。


  • 在状态机中使用枚举命名您的状态,它将使代码读取更容易,并消除始终是维护问题的幻数。
  • 状态50和51(至少),你期待一个CR或LF,但如果它没有通过角色到达你。如果出现数据错误且CR或LF丢失怎么办?如果Telit配置为不发送CR或LF(这是可能的),该怎么办?你扔掉的那个角色可能是好的O或RING的R。状态机对意外情况的抵抗力不强。
  • 您没有错误处理,大多数UARTS抛出错误中断。
  • 您不会在任何结尾处传输CR或CRLF。在AT命令中,AT命令协议使用CR或CRLF作为命令结束的分隔符。如果没有CR或CRLF,您还没有完成命令,Telit命令处理器将不解析它并对其进行操作。
  • 第176行。发送AT。自动波特率。这很好,但是当你发送它时你不知道Telits命令处理器的状态。最好先用几个CR(或CRLF)来清除它,比如
Firstly I would like to say I have used both these products without a problem. Admittedly not together I used a PIC with a Semiens GSM module and a Telit GSM module with a Cyan microprocessor.

You have a number of issues in you code that are not good. They may or may not be causing a problem.

Firstly I assume that you have actually connected the TX pin of the PIC to the RX pin of the Tellit and vice versa.


  • In the state machine use an enum to name your states, it will make reading the code a lot easier and eliminate magic numbers that are always a maintenance issue.
  • State 50 and 51 (at least), you are expecting a CR or LF but if it doesn''t arrive you through the character away. What if there was a data error and the CR or LF was lost? What if the Telit is configured to not send either CR or LF (which is possible). That character you are throwing away could be the ''O'' of OK or ''R'' of RING. The state machine is not very resilient to the unexpected.
  • You have no error handling, most UARTS throw error interrupts.
  • You do not transmit a CR or CRLF at the end of any of your AT commands, the AT command protocol uses the CR or CRLF as the delimiter for the end of the command. Without the CR or CRLF you have not finished the command and the Telit command processor will not parse it and action it.
  • Line 176. Sending "AT" to auto baud. That is fine but you do not know the state of the Telits command processor when you send it. Better to clear it down with a few CR (or CRLF) first, something like
  1. 发送CR
  2. 短暂停留
  3. 发送CR
  4. 短暂停留
  5. 发送CR
  6. 短暂停留
  7. 发送AT\r
  8. 长时间暂停
  9. 如果你没有得到确认,那么转到1

Telit可以自动波特率任意角色,所以希望CR序列允许它自动-baud和第一个AT将起作用。它还将重置Telits命令处理器,因此肯定会期待AT

  • 您的程序代码对命令不起作用没有弹性。
  • The Telit can auto baud off any character so hopefully the CR sequence will allow it to auto-baud and the first AT will work. It will also reset the Telits command processor so it will definitely be expecting an AT

  • Your program code has no resilience to commands not working.

  • 非常感谢您的回答。

    是的,我确实将TX连接到RX,反之亦然。

    当我编译时,我是使用MPLAB的新手它没有错误地构建它的程序。


    我有几个问题,这个代码是从供应商处获得的,但最初是用于另一个主板,但仍然使用图片。


    @第46行:

    tmp = ReadUSART();


    在供应商示例中,他使用的是Read1Usart()但是我尝试使用read1usart进行编译它不起作用,所以我将其更改为readUS。

    Mplab告诉我,我没有在USART中定义它.H

    我允许这样做吗?或者是为什么我什么都不读? (因为我正在使用write1,purts1等..但是readUsart)


    谢谢......
    Thank you very much for your answer.
    Yes I did connected TX to RX and vis versa.
    I''m new at using MPLAB, when I compiled the program it builds it with no error.

    I have a couple question, this code was taken from the vendor but was originally for another board but still using a pic.

    @ line 46:
    tmp = ReadUSART();

    On the vendor example he was using Read1Usart() but when I try to compile with read1usart it doesn''t work, so I changed it to readUSART.
    Mplab tells me that I did not define it in the USART.H
    Am I allow to do so? Or is it why I do not read anything? (since I''m using write1, purts1 etc.. but readUsart)

    Thank you...


    你好,

    好​​的,所以我想我得到了一点点

    测试我的程序时,我的程序被卡在循环中找到波特率..你能帮我调试一下吗? />

    我尝试了几种方法(强制波特率为9600)但是也没有工作......


    也可以尝试我的pgm我做错了,我正在插入一张SIM卡并检查状态指示灯(GM862上的引脚22),但是由于没有找到网络,指示灯仍然快速闪烁..所以我知道(或者我认为)我的pgm是不工作


    阅读你的帖子,你说了一些关于处理错误的事情,但我是新手,我不知道该怎么写。你有任何改变代码吗?在哪里实现它?


    Hello,
    Ok so I think I got a little bit further
    when testing my the program below my progam is stuck in the loop to find the baudrate.. Can you help me debug this?

    I tried several method (forcing the baudrate to be 9600) but did not work either...

    Also to try my pgm maybe I''m doing it wrong, I''m inserting a sim card and check the status led (pin 22 on GM862) but the led keeps blinking fast as it doesnt find a network.. so I know (or I think) my pgm is not working

    Reading your post, you said something about handling error, but I''m pretty new to this and I dont know what to write. Would you have a code for it by any change? and where to implement it?



    展开 | 选择 | Wrap | 行号


    这篇关于在C中编程GM862的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆