This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi Team,
If you look at SPI configuration in the example spi_ex4_eeprom and in the hal.c file of the InstaSPIN-FOC implementation, the set bitRate value (in comments) is different then the argument passed in the SPI_setConfig() function. This doesn't make sense because it doesn't follow the baud rate calculation explained on the page 2216 of the SPRUI33C.
How to calculate bitRate argument for SPI_setConfig() function from the desired bitRate setting for SPI communication? Please look at the code from the both the example.
// SPI configuration from the spi_ex4_eeprom example // SPI configuration. Use a 2MHz SPICLK and 8-bit word size. // SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA1, SPI_MODE_MASTER, 1000000, 8); // SPI configuration from the hal.c of InstaSPIN-FOC // SPI configuration. Use a 1MHz SPICLK and 16-bit word size. 500kbps SPI_setConfig(obj->spiHandle[0], DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0, SPI_MODE_MASTER, 400000, 16);
Amit,
You are right on the comments. Comments on both of them are wrong and needs to be fixed.
Here are the correct comments:-
In spi_ex4_eeprom example, SPI baud rate is 1MHz and 8-bit word size
In hal.c, SPI baud rate is 400 KHz and 16-bit word size
I however, don’t agree that SPI baudrate calculation is wrong. It is indeed correct. Below calculation is derived from equation 8 found in Pg:2216 and this is what is used in spi.c
SPIBRR = (LSPCLK / SPI Buad rate) – 1
Regards,
Manoj
Manoj,
That's exactly what I had thought but wanted to clarify with TI. Thanks for clarifying.
Best,
Amit