Help us improve the Power & Sensing Selection Guide. Share feedback

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

cross mob
Not applicable
Does anyone have pre-calculated defines to set some common baud rates for an XMC1302. (9600, 19200, 38400, 115200)

The only set I have at the moment is:
// UART baud rate constants for 57.8kbps @ MCLK=8MHz
#define FDR_STEP 590UL
#define BRG_PDIV 4UL
#define BRG_DCTQ 15UL
#define BRG_SP 9UL
#define BRG_PCTQ 0UL

I tried using the ConfigureBaudRate() function (380 lines of code....incredible!)

Did not seem to provide correct values. Would be easier to get pre-calculated defines and put them in a table.
I noticed that event the sample programs do this rather than use ConfigureBaudRate().
2 Replies
Not applicable
DCTQ, PCTQ and SP values can be kept the same and since all these baud rates are of a fixed factor from one another, it is easy to find first the STEP value and then from there derive the various PDIV values.
Note that the actual divider factor is given by PDIV+1.
With that, I can suggest the following:

// UART baud rate constants @MCLK=8MHz
#define FDR_STEP 472UL
#define BRG_PDIV 1UL //for 115.2kbps
// #define BRG_PDIV 3UL //for 57.6kbps
// #define BRG_PDIV 5UL //for 38.4kbps
// #define BRG_PDIV 11UL //for 19.2kbps
// #define BRG_PDIV 23UL //for 9.6kbps
Not applicable
Thanks T.O.M.
The defines you suggested worked.