Part Number: EK-TM4C1294XL
Tool/software:
Hi Team,
We are using the EC21-E Quectel GSM module to push data to the MQTT server. The EK-TM4C1294XL controller is connected to the GSM module via UART0 (PA0, PA1 - modem flow control and modem status). We are unable to receive the response from the GSM module using UART0 alone. I have tried the same setup with connecting GSM module from UART2 to UART7 at a baud rate of 115200. It works fine with UART2 to UART7, but UART0 and UART1 is not functioning as expected. We also tested UART0 and UART1 manually using UART to USB converter to send and receive data, and it works fine, but with the GSM module alone, we are not getting a response.
Code1: UART6 for communication with EC21E GSM module UART0 for debugging
#include <stdint.h> //U6-c U0-d
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include <string.h>
#define GSM_BUFFER_SIZE 128
uint32_t g_ui32SysClock;
char GSM_Buffer[GSM_BUFFER_SIZE];
uint32_t g_ui32BufferIndex = 0;
void UART6Write(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
while (ui32Count--)
{
ROM_UARTCharPut(UART6_BASE, *pui8Buffer++);
}
while (ROM_UARTBusy(UART6_BASE)) {}
}
void UART0Write(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
while (ui32Count--)
{
ROM_UARTCharPut(UART0_BASE, *pui8Buffer++);
}
while (ROM_UARTBusy(UART0_BASE)) {}
}
void SendCommand(const char *command)
{
char cmd_message[50];
snprintf(cmd_message, sizeof(cmd_message), "\r\nCommand sent: %s\r\n", command);
UART0Write((uint8_t *)cmd_message, strlen(cmd_message));
UART6Write((uint8_t *)command, strlen(command));
}
void UARTIntHandler(void)
{
uint32_t ui32Status;
ui32Status = ROM_UARTIntStatus(UART6_BASE, true);
ROM_UARTIntClear(UART6_BASE, ui32Status);
while (ROM_UARTCharsAvail(UART6_BASE))
{
char receivedChar = ROM_UARTCharGetNonBlocking(UART6_BASE);
if (g_ui32BufferIndex < GSM_BUFFER_SIZE - 1)
{
GSM_Buffer[g_ui32BufferIndex++] = receivedChar;
if (receivedChar == '\n' || receivedChar == '\r')
{
GSM_Buffer[g_ui32BufferIndex] = '\0';
UART0Write((uint8_t *)GSM_Buffer, g_ui32BufferIndex);
g_ui32BufferIndex = 0;
}
}
}
}
int main(void)
{
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART6);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PP0_U6RX);
GPIOPinConfigure(GPIO_PP1_U6TX);
ROM_GPIOPinTypeUART(GPIO_PORTP_BASE, GPIO_PIN_0 | GPIO_PIN_1);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
ROM_UARTConfigSetExpClk(UART6_BASE, g_ui32SysClock, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
ROM_UARTConfigSetExpClk(UART0_BASE, g_ui32SysClock, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
UARTIntRegister(UART6_BASE, UARTIntHandler);
ROM_UARTIntEnable(UART6_BASE, UART_INT_RX | UART_INT_RT);
ROM_IntEnable(INT_UART6);
ROM_IntMasterEnable();
SendCommand("ATE0\r\n");
SysCtlDelay(2000000);
SendCommand("AT\r\n");
SysCtlDelay(2000000);
while (1) {}
}
Code2: UART0 for communication with EC21E GSM module UART6 for debugging
#include <stdint.h> //U0-c U6-d
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include <string.h>
#define GSM_BUFFER_SIZE 128
uint32_t g_ui32SysClock;
char GSM_Buffer[GSM_BUFFER_SIZE];
uint32_t g_ui32BufferIndex = 0;
void UART6Write(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
while (ui32Count--)
{
ROM_UARTCharPut(UART6_BASE, *pui8Buffer++);
}
while (ROM_UARTBusy(UART6_BASE)) {}
}
void UART0Write(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
while (ui32Count--)
{
ROM_UARTCharPut(UART0_BASE, *pui8Buffer++);
}
while (ROM_UARTBusy(UART0_BASE)) {}
}
void SendCommand(const char *command)
{
//char cmd_message[50];
//snprintf(cmd_message, sizeof(cmd_message), "\r\nCommand sent: %s\r\n", command);
//UART6Write((uint8_t *)cmd_message, strlen(cmd_message));
UART6Write((uint8_t *)command, strlen(command));
UART0Write((uint8_t *)command, strlen(command));
}
void UARTIntHandler(void)
{
uint32_t ui32Status;
ui32Status = ROM_UARTIntStatus(UART0_BASE, true);
ROM_UARTIntClear(UART0_BASE, ui32Status);
while (ROM_UARTCharsAvail(UART0_BASE))
{
char receivedChar = ROM_UARTCharGetNonBlocking(UART0_BASE);
if (g_ui32BufferIndex < GSM_BUFFER_SIZE - 1)
{
GSM_Buffer[g_ui32BufferIndex++] = receivedChar;
if (receivedChar == '\n' || receivedChar == '\r')
{
GSM_Buffer[g_ui32BufferIndex] = '\0';
UART6Write((uint8_t *)GSM_Buffer, g_ui32BufferIndex);
g_ui32BufferIndex = 0;
}
}
}
}
int main(void)
{
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART6);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PP0_U6RX);
GPIOPinConfigure(GPIO_PP1_U6TX);
ROM_GPIOPinTypeUART(GPIO_PORTP_BASE, GPIO_PIN_0 | GPIO_PIN_1);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
ROM_UARTConfigSetExpClk(UART6_BASE, g_ui32SysClock, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
ROM_UARTConfigSetExpClk(UART0_BASE, g_ui32SysClock, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
UARTIntRegister(UART0_BASE, UARTIntHandler);
ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
ROM_IntEnable(INT_UART0);
ROM_IntMasterEnable();
SendCommand("ATE0\r\n");
SysCtlDelay(2000000);
SendCommand("AT\r\n");
SysCtlDelay(2000000);
while (1) {}
}
Please help us to resolve this issue.
