XMC4800 app UART DAVE calculates BRG value wrong when using 18 MBaud

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User7795
Level 4
Level 4
Hi Infineon,

DAVE4.4.2 app UART calculates BRG value wrong when using Baud=18.000.000 and oversampling=8.
Using Baud=9.000.000 and oversampling=8 results in BRG=0x00001c00, which works fine, but doubling baudrate results in BRG=0xF3FF1C00, i.e. PDIV=1024, thats wrong. No initialization error occurs.

At the moment, it's not posssible to open a ticket because of maintenance.

Best Regards
Wolfgang
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

Thanks for reporting the issue.
In the mean time you can try with the fixes proposed below:

XMC_USIC_CH_STATUS_t XMC_USIC_CH_SetBaudrate(XMC_USIC_CH_t *const channel, uint32_t rate, uint32_t oversampling)
{
XMC_USIC_CH_STATUS_t status;

uint32_t peripheral_clock;

uint32_t clock_divider;
uint32_t clock_divider_min;

uint32_t pdiv;
uint32_t pdiv_int;
uint32_t pdiv_int_min;

uint32_t pdiv_frac;
uint32_t pdiv_frac_min;

/* The rate and peripheral clock are divided by 100 to be able to use only 32bit arithmetic */
if ((rate >= 100U) && (oversampling != 0U))
{
peripheral_clock = XMC_SCU_CLOCK_GetPeripheralClockFrequency() / 100U;
rate = rate / 100U;

clock_divider_min = 1024U;
pdiv_int_min = 1U;
pdiv_frac_min = 0x3ffU;

for(clock_divider = 1024U; clock_divider > 0U; --clock_divider)
{
pdiv = ((peripheral_clock * clock_divider) / (rate * oversampling));
pdiv_int = pdiv >> 10U;
pdiv_frac = pdiv & 0x3ffU;

if ((pdiv_int <= 1024U) && (pdiv_frac < pdiv_frac_min))
{
pdiv_frac_min = pdiv_frac;
pdiv_int_min = pdiv_int;
clock_divider_min = clock_divider;
}
}

channel->FDR = XMC_USIC_CH_BRG_CLOCK_DIVIDER_MODE_FRACTIONAL |
((clock_divider_min - 1) << USIC_CH_FDR_STEP_Pos);

channel->BRG = (channel->BRG & ~(USIC_CH_BRG_DCTQ_Msk |
USIC_CH_BRG_PDIV_Msk |
USIC_CH_BRG_PCTQ_Msk |
USIC_CH_BRG_PPPEN_Msk)) |
((oversampling - 1U) << USIC_CH_BRG_DCTQ_Pos) |
((pdiv_int_min - 1U) << USIC_CH_BRG_PDIV_Pos);

status = XMC_USIC_CH_STATUS_OK;
}
else
{
status = XMC_USIC_CH_STATUS_ERROR;
}

return status;
}



Regards,
Jesus
0 Likes
User7795
Level 4
Level 4
Thanks Jesus for the fast response,

it's running.

A little addition: the modifications have to be done at file
/Libraries/XMCLib/src/xmc_usic.c
(function starts at line 120)

then save the file and compile project again.

Best Regards
Wolfgang
0 Likes