Other Parts Discussed in Thread: HALCOGEN
Hello,
I am using "sciSetBaudrate" API function generated by HALCOGEN version 4.7 to updated SCI interface baud rate.below the API code generated by HALCOGEN
void sciSetBaudrate(sciBASE_t *sci, uint32 baud)
{
float64 vclk = 90.000 * 1000000.0;
uint32 f = ((sci->GCR1 & 2U) == 2U) ? 16U : 1U;
uint32 temp;
float64 temp2;
/*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);
}
I am trying to set baud rate as 115200 for which the prescaler value will be 10. "floor" function is returning correct prescaler value but the value copied in to temp2 variable is wrong there by configuring wrong prescaler vale. can you please help me to fix this issue?
Thanks,
Kalyan