Hi,
Reading the tivaware library documentation and some example code, I see that the uart clock passed to the UARTConfigSetExpClk function is the value returned by SysCtlClockGet(), but in my case that doesn't work and I wonder why.
I configure the system clock as:
/* Set system clock */
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
Then, in the uart configuration steps, I have to set the uart clock manually to 16000000 for it to work:
ROM_UARTConfigSetExpClk(UART0_BASE, 16000000, 115200,
(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |UART_CONFIG_WLEN_8));
Because if I use SysCtlClockGet() instead of 16000000 the baudrate is not set properly and I receive garbage through the serial port
ROM_UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |UART_CONFIG_WLEN_8)); // THIS DOESN'T SEEM TO SET THE BAUDRATE PROPERLY
Can someone explain me why, if I use SysCtlClockGet() (that is actually returning 40000000), it doesn't work? I thought that the uart peripheral clock was the same as the system clock.
Thanks