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.

RM48L952: RM48L952 sci baudrate question

Part Number: RM48L952
Other Parts Discussed in Thread: HALCOGEN

Dear Sir:

sci module question:

set baudrate used this sub-function:

/** @fn void sciSetBaudrate(sciBASE_t *sci, uint32 baud)
* @brief Change baudrate at runtime.
* @param[in] sci - sci module base address
* @param[in] baud - baudrate in Hz
*
* Change the SCI baudrate at runtime.
*/
/* SourceId : SCI_SourceId_003 */
/* DesignId : SCI_DesignId_003 */
/* Requirements : HL_SR232 */
void sciSetBaudrate(sciBASE_t *sci, uint32 baud)
{

float64 vclk = 110.000 * 1000000.0;
uint32 f = ((sci->GCR1 & 2U) == 2U) ? 16U : 1U;
uint32 temp;
float64 temp2;
/* USER CODE BEGIN (6) */
/* USER CODE END */

/*SAFETYMCUSW 96 S MR:6.1 <APPROVED> "Calculations including int and float cannot be avoided" */
temp = (f*(baud));
temp2 = ((vclk)/((float64)temp))-1U;
temp2 = floor(temp2 + 0.5); /* Rounding-off to the closest integer */
sci->BRS = (uint32)((uint32)temp2 & 0x00FFFFFFU);


/* USER CODE BEGIN (7) */
/* USER CODE END */
}

I connect with PC COM1 port( physical port, not USB <->UART) 

TX  can do 115200/57600 ~ 9600/4800/2400/1200 baudrate

RX can do 115200/57600 ~ 9600, but the 4800/2400/1200 baudrate out ot function

  • Hello Ken,
    Could you tell me BRS value which is loaded by sciSetBaudrate?

    Best regards,
    Miro
  • Dear Miro:

    I used this sub-function as below , it is gen. by HALCoGen

    void sciSetBaudrate(sciBASE_t *sci, uint32 baud)
    {

    float64 vclk = 110.000 * 1000000.0;
    uint32 f = ((sci->GCR1 & 2U) == 2U) ? 16U : 1U;
    uint32 temp;
    float64 temp2;

    temp = (f*(baud));
    temp2 = ((vclk)/((float64)temp))-1U;
    temp2 = floor(temp2 + 0.5); /* Rounding-off to the closest integer */
    sci->BRS = (uint32)((uint32)temp2 & 0x00FFFFFFU);

    }

    and this function OK for TX , Baudrate 115200/57600/38400....9600/4800/2400/1200 , all OK
    but for RX 115200/57600/38400....9600 OK , 4800/2400/1200 not OK

    I try another methed
    void sciSetBaudrate(sciBASE_t *sci, uint32 baud)
    {
    /** - set baudrate */
    scilinREG->BRS = 1431; /* pre-scale 1431 = 4800 pbs*/
    }

    I try the pre-scale 1435 ~ 1427 for 4800 pbs , no way
    the pre-scale 2864 for 2400 pbs, I try 2869 ~ 2859 , no way!

    I say again , TX is OK , only RX no way on 4800/2400/1200 bps

    Best Regards

    Ken Lin