AnsweredAssumed Answered

Bug in fsl_uart.c for LPC802 (assertion)?

Question asked by Karlheinz Wuersch on Apr 30, 2019
Latest reply on May 8, 2019 by Felipe García

Original code in fsl_uart.c

------------------------------------------------------------------------------------------------

status_t USART_SetBaudRate(USART_Type *base, uint32_t baudrate_Bps, uint32_t srcClock_Hz):

 

Line 354:

 

        /* value over range */
        if (best_brgval > 0xFFFF)
        {
            return kStatus_USART_BaudrateNotSupport;
        }

 

        /* If the baud rate caculated is not very precise, please select the FRG clock as
         * the USART's source clock, and set the FRG frequency to a more suitable value.
         */
        assert(diff < ((baudrate_Bps / 100) * 3));       <------ wrong?

 

        base->OSR = best_osrval;
        base->BRG = best_brgval;
    }

--------------------------------------------------------------------------------------------

In case of setting 115200 baud the assert happens.

 

I have changed the following  >>> assert(best_diff < ((baudrate_Bps / 100) * 3)); <<<< to avoid the

assert, because 115.200 is a valid value in case of a 15MHz system or main clock is used.

 

Correct change?

Outcomes