cancel
Showing results for 
Search instead for 
Did you mean: 

Setting 38400 baud rate reception with SPI

rohan_m
Senior

Need to achieve 38400 baud rate for reception of NMEA messages but here 38400 is not in the multiple of binary numbers.

Setting the clock to 8MHz and then using prescaler is just setting it to 31.25 Kb.

rohan_m_0-1707383007686.png

How to adjust to be able to achieve that baud rate ?

3 REPLIES 3
SofLit
ST Employee

Hello,

I think you can use PLL for this.

I had a trial and achieved 38.411Kb/s . I don't know if it does fit your expectation:

SofLit_0-1707386786041.png

SofLit_1-1707386854731.png

 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
TDK
Guru

Typically, SPI speed is specified as a maximum speed. Have never seen a chip which required an exact SPI clock frequency.

What chip? Are you sure you're not mixing up SPI and UART? 38400 sounds like a UART baud rate from a GPS receiver.

If you feel a post has answered your question, please click "Accept as Solution".
Peter BENSCH
ST Employee

I also suspect an UART output, as this is typically used for NMEA messages, as @TDK said. But even then you don't have to hit 38400 to several decimal places because UART works with oversampling and has a certain frequency tolerance - 1% deviation is no problem at all, and the proposal of @SofLit is only 0.029% off.

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.