Other Parts Discussed in Thread: TM4C1230D5PM
Hi All.
I know this question has kinda been asked before, but I could not find any clear-cut answer.
Let me explain our setup.
We have a Telit-GSM module interfaced with the TM4C1230D5PM, and this includes the interfacing of RTS/CTS pins.
In code, we have done the following ::
/*
* Initialize the UART1.
*/
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
/*
* Set up the RTS/CTS pins.
*/
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinConfigure(GPIO_PF0_U1RTS);
GPIOPinConfigure(GPIO_PF1_U1CTS);
ROM_GPIOPinTypeUART(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1);
/*
* Set up the RX/TX pins.
*/
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIOPinConfigure(GPIO_PC4_U1RX);
GPIOPinConfigure(GPIO_PC5_U1TX);
ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5);
/*
* Configure the UART for 9600, 8-N-1 operation.
*/
ROM_UARTConfigSetExpClk(UART1_BASE, ROM_SysCtlClockGet(), 9600,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
/*
* Final UART1-initializations.
*/
ROM_UARTFIFOEnable(UART1_BASE);
ROM_UARTEnable(UART1_BASE);
/*
* Enable the interrupts (only RX).
*/
ROM_IntEnable(INT_UART1);
UARTIntDisable(UART1_BASE, UART_INT_TX);
ROM_UARTIntEnable(UART1_BASE, UART_INT_RX);
Also, following is the Interrupt-Handler (UART1Handler, // UART1 Rx and Tx)
static void
UART1Handler(void)
{
unsigned long interrupts;
interrupts = UARTIntStatus(UART1_BASE, true);
info_log("0x%x", interrupts);
UARTIntClear(UART1_BASE, interrupts);
if(1)
{
while(ROM_UARTCharsAvail(UART1_BASE))
{
info_log("[%c]", ROM_UARTCharGetNonBlocking(UART1_BASE));
}
}
ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_PIN_1);
info_log("exiting");
}
("info_log" is a library function of ours, which just writes to a serial UART0 to a console).
Now, when we power on the board, we send a "AT+CGSN\r\n" command to Telit-Module (via UART1), and thereafter enter into infinite-loop in the main-thread.
Thereafter, the interrupt-handler (UART1Handler) gets called JUST ONCE, and exactly 16 bytes are read every time.
Please note that if we use any other permutation (like disabling RTS/CTS, and/or disabling interrupts), the behaviour is not consistent, and sometimes 14/15/16/17 bytes are read. With RTS/CTS enabled and interrupts enabled, we are at least getting a consistent behaviour (of exactly 16 bytes being read every time).
What needs to be done, so that the complete response can be read in a deterministic, consistent manner? I guess we need to do something extra with RTS/CTS, but can't figure it out.
Will be grateful for any pointers to hit the needle in the hay.
Thanks and Regards,
Ajay