XMC4700 SPI configuration --> SCLK = 8 KHz

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

cross mob
User13334
Level 2
Level 2
Good Morning Forum Member,

I want to generate a SCLK frequence of 8 kHz, by SPI I can said that this is equal tp 8 kbit/s correct?

now I have the problem which baudrate (nummeric value) is nessessary that the XMC LIB function




/**
* Structure for initializing SPI channel.
*/
typedef struct XMC_SPI_CH_CONFIG
{
uint32_t baudrate; /**< Module baud rate for communication */
XMC_SPI_CH_BUS_MODE_t bus_mode; /**< Bus mode: Master/Slave */
XMC_SPI_CH_SLAVE_SEL_MSLS_INV_t selo_inversion; /**< Enable inversion of Slave select signal relative to the internal
MSLS signal */
XMC_USIC_CH_PARITY_MODE_t parity_mode; /**< Enable parity check for transmit and received data */
} XMC_SPI_CH_CONFIG_t;




That the function below, called by XMC_SPI_CH_Init is set the register that the clock is work with 8 kHz


XMC_SPI_CH_STATUS_t XMC_SPI_CH_SetBaudrate(XMC_USIC_CH_t *const channel, const uint32_t rate)
{
XMC_SPI_CH_STATUS_t status;

status = XMC_SPI_CH_STATUS_ERROR;

if (rate <= (XMC_SCU_CLOCK_GetPeripheralClockFrequency() >> 1U))
{
if (XMC_USIC_CH_SetBaudrate(channel, rate, XMC_SPI_CH_OVERSAMPLING) == XMC_USIC_CH_STATUS_OK)
{
status = XMC_SPI_CH_STATUS_OK;
}
}
return status;
}




Remarks: Frequency calculation by XMC Datasheet

fpheriph = 144 MHz --> 1/1000 (Fractional Devider) --> f = 144 kHz ---> PDIV f*1/9 ---> f = 16 KHz --> Div by 2 f*1/2 --> fsclk = 8 KHz

But what value I need for uint32_t baudrate to set the register that the frequency calculation above is made.

Best regards

Ebbe Sand
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

.baudrate = 8000,


Should do it??

Regards,
Jesus
0 Likes
User13334
Level 2
Level 2
Hi Jesus,

Sometimes things can be so easy that you can believe it. But now for your question yes it works.
Thanks for your help and a successful week.

Best regards

Ebbe Sand
0 Likes