Sep 24, 2019
09:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 24, 2019
09:21 AM
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
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
- Tags:
- IFX
2 Replies
Sep 25, 2019
06:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 25, 2019
06:07 AM
Hi,
Thanks for reporting the issue.
In the mean time you can try with the fixes proposed below:
Regards,
Jesus
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
Sep 25, 2019
08:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 25, 2019
08:34 AM
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
it's running.
A little addition: the modifications have to be done at file
(function starts at line 120)
then save the file and compile project again.
Best Regards
Wolfgang