Closed
Description
The first Serial.print() in a sketch is displaying garbage
Reproduce
Create a sketch, in setup
Serial.begin(115200);
Serial.println(Test1);
Serial.println(Test2);
Compile and load and start. The Test1 will be displayed as with garbage
or as Garbage. Test2 will show normal
Root cause
First initialize the UART, then intialise the pin
Solution
Change the UART initialization before the PIN setup
########### in ap3_uart.cpp ################
**************routine _begin(void) ******************
after the testing for a valid pin move :
//User may want to change settings mid-sketch. Only init UART if it's new.
if (_handle == NULL)
{
// Now that pins are initialized start the actual driver
retval = (ap3_err_t)am_hal_uart_initialize(_instance, &_handle);
if (retval != AP3_OK)
{
return ap3_return(retval);
}
}
retval = (ap3_err_t)am_hal_uart_power_control(_handle, AM_HAL_SYSCTRL_WAKE, false);
if (retval != AP3_OK)
{
return ap3_return(retval);
}
retval = (ap3_err_t)am_hal_uart_configure(_handle, &_config);
if (retval != AP3_OK)
{
return ap3_return(retval);
}
UARTn(_instance)->LCRH_b.FEN = 0; // Disable that pesky FIFO
********************** NOW SET THE PINS ************************
********************** THEN ************************************
// Enable TX and RX interrupts
NVIC_EnableIRQ((IRQn_Type)(UART0_IRQn + _instance));
am_hal_uart_interrupt_enable(_handle, (AM_HAL_UART_INT_RX | AM_HAL_UART_INT_TX));
am_hal_interrupt_master_enable();
// Service interrupts to determine idle state
am_hal_uart_interrupt_service(_handle, 0, (uint32_t *)&_tx_idle);
// Register the class into the local list
ap3_uart_handles[_instance] = this;
return retval;
Metadata
Metadata
Assignees
Labels
No labels