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.

[参考译文] 编译器:连接 SIM800 GSM 模块与 TM4c (通过 UART)

Guru**** 2457760 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/647863/compiler-interfacing-sim800-gsm-module-to-tm4c-via-uart

工具/软件:TI C/C++编译器

  目前我正在使用 TM4C123GH6PM 微控制 器、在这里、我已经将我的微控制器连接到 SIM800 GSM/GPRS 模块。当我从控制器传输命令时、只有头两个命令发送时、我想发送多个命令。  

在这里,我修改了 UART 回波示例....

#include
#include
#include
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include


#define test "at\r\n"0
#define CSTT "\"AT+CSTT="BSNLNET\"\n\n\r\n"
#define CIICR "AT+CIICR\r\n0"
uint32_t uiFreq;

char receivechar;
uint8_t ui32i = 0;


空 UARTTransmitCommand (char *cmd) //使用 UART 发送 AT 命令

while (UARTBusy (UART5_BASE));
while (*cmd!='\0')

UARTCharPut (UART5_BASE、* CMD++);

空 UARTIntHandler (空)

uint32_t ui32Status;
ui32Status = UARTIntStatus (UART5_BASE、TRUE);//获取中断状态
UARTIntClear (UART5_BASE、ui32Status);//清除已发出的中断
while (UARTCharsAvail (UART5_BASE))//循环(有字符时)

//从 UART 读取下一个字符并将其写回 UART。
//

while (ui32i!=35){
receivechar=UARTCharGet (UART5_BASE);
UARTCharPut (UART0_BASE、receivechar);
ui32i++;

ui32i=0;

//延迟1毫秒。 每个 SysCtlDelay 大约为3个时钟。
//
SysCtlDelay (uiFreq /(1000 * 3));



int main (void){

//禁用所有中断
IntMasterDisable();

// UART 0
SysCtlClockSet (SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHz);
SysCtlPeripheralEnable (SYSCTL_Periph_UART0);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOA);
GPIOPinConfigure (GPIO_PA0_U0RX);
GPIOPinConfigure (GPIO_PA1_U0TX);
GPIOPinTypeUART (GPIO_Porta_base、GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk (UART0_BASE、SysCtlClockGet ()、115200、
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);
// UART 5.

SysCtlClockSet (SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHz);
SysCtlPeripheralEnable (SYSCTL_Periph_UART5);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOE);
GPIOPinConfigure (GPIO_PE4_U5RX);
GPIOPinConfigure (GPIO_PE5_U5TX);
GPIOPinTypeUART (GPIO_Porte _BASE、GPIO_PIN_4 | GPIO_PIN_5);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF);//为 LED 启用 GPIO 端口
GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE、GPIO_PIN_2);//针对 LED PF2的使能引脚
UARTConfigSetExpClk (UART5_BASE、SysCtlClockGet ()、115200、
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);
IntMasterEnable();//启用处理器中断
IntEnable (INT_UART5);//启用 UART 中断
UARTIntEnable (UART5_BASE、UART_INT_RX | UART_INT_RT);//仅启用 RX 和 TX 中断

//主设备启用所有中断
IntMasterEnable();

UARTTransmitCommand (TEST);
UARTTransmitCommand (CSTT);
SysCtlDelay (200000);
UARTTransmitCommand (CIICR);

而(1)//let 中断处理程序执行 UART 回显功能


  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    能否在 UARTIntHandler 内部尝试 UARTCharGetNonBlocking()和 UARTCharPutNonBlocking()?
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    是的,我在 UARTIntHandler 内尝试过 UARTCharGetNonBlocking()和 UARTCharPutNonBlocking(),但问题相同