I have a problem about the baud rate of linflexd_uart in MPC5746R.
I set the baud rate at 9600 but i can't get the 9600 baud rate information in Oscilloscope.
I didn't know what's problem with this. Can you help me ?
I want to send the date by MPC5746R and receive the date by the computer.
This is my code about uart.
/* Write your local variable definition here */
#define BUF_LEN 1U
uint8_t rxBuff[BUF_LEN + 1];
uint16_t RX_ok = 0x23U;
/* Store configuration into structure */
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
/* Change clock settings */
/* Initialize Pin Settings */
/* Initialize Uart */
LINFLEXD_UART_DRV_Init(INST_LINFLEXD_UART1, &linflexd_uart1_State, &linflexd_uart1_InitConfig0);
LINFLEXD_UART_DRV_Init(INST_LINFLEXD_UART2, &linflexd_uart2_State, &linflexd_uart2_InitConfig0);
// LINFLEXD_UART_DRV_ReceiveDataBlocking(INST_LINFLEXD_UART1, (uint8_t*)rxBuff, BUF_LEN, 300U);
// LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART2,(uint8_t*)test_mode, BUF_LEN,300U);
LINFLEXD_UART_DRV_SendData(INST_LINFLEXD_UART2, (uint8_t*)test_mode, BUF_LEN);
// if ( rxBuff == 1)
// RX_ok = 1;
My rose =0 , LINIBRR = 0x068 (Hex) = 104 d ,LIN_clk = 16Mhz.
baud rate = 16M/(16*104) = 9615 bit/s.
the width of date is 16.8us but 9600 baud rate is 104us.
I investigated the issue and indeed there seems to be a confusion in the clock configuration.
According to the reference manual:
LINFLEXD clock source can be changed through Device Configuration records, which are write-once and not configurable through the SDK. Nevertheless, the SDK only considers one of the two options, which apparently is not the correct one on your side.
In your case, the LIN peripheral clock must be SYS_CLK.
As a workaround to get the desired baudrate you need to have the same frequency configured for SYS_CLK and LINFLEX instances (either change LIN clock source to PLL or change sys_clk source to IRCOSC):
(in the latter case you'll get a warning, as LIN peripheral clock is supposed to be less than 80MHz).
Another solution (a bit more complicated) would be to write the appropriate DCF entry to switch to the other LINFLEX clocking option (please check section 18.104.22.168 in the reference manual).
Hope this helps!