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.

UART problem with stop bit



Hello! 

I am working on reading data from GPS module. I think I am stuck at here:  

UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(),9600, 0x00000060 |UART_CONFIG_STOP_ONE| UART_CONFIG_PAR_NONE);

In the code above, I want to make a change so that the stop bit is 0, instead of choosing either one or two. This is to read data from a GPS module. Currently it returns messy code. I have tried many combinations but none of them works. However, I know the module works because I have tried it on Arduino before.  Is there a way to customize communication protocol?

The manual of GPS EM-406a says

"The default communication parameters for PORT B are set for 9600 Baud, 8data bits, 0 stop bits, and no parity."

Also attached is my entire code:

int x=0;
int main(void) {

SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB0_U1RX);
GPIOPinConfigure(GPIO_PB1_U1TX);
GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(),9600, 0x00000060 |UART_CONFIG_STOP_ONE| UART_CONFIG_PAR_NONE);


SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
UARTStdioConfig(0, 9600, 16000000);

UARTprintf("flag!! \n");

while (1) {
char data;

while(UARTCharsAvail(UART1_BASE)) {
data = UARTCharGetNonBlocking(UART1_BASE);
UARTprintf("%c", data) ;
x++;
if (x>=20) {
x=0;
UARTprintf("\n") ;
}
}

}
}

  • Yucheng Guo said:
    In the code above, I want to make a change so that the stop bit is 0

    Stop bits are necessary, even if it were possible to set the number to zero you would not want to.

    It sounds like you have a baud rate mismatch. I'd check your baud rate with an oscilloscope.

    Robert