barco hes

QSPI Buad Rate divisor in polled mcf5xxx_qspi.c

Discussion created by barco hes on Nov 30, 2010
Latest reply on Dec 3, 2010 by barco hes

It looks like the baud rate divisor is miscalculated for polled qspi in mqx 3.6.2.


In the file mqx/source/io/spi/polled/spi_pol_mcf5xxx_qspi.c the function  _mcf5xxx_qspi_find_baudrate()



The divisor is calculated as


    div=(clock + (baudrate >> 1)) / baudrate;


I think it should be


   div=clock / (baudrate << 1);


I am using the mfc52223 and the reference manual states that the calculation for the divisor is



QMR[BAUD] = clock / (2 × [desired QSPI_CLK baud rate]). We have the processor running on 80,000,000hz, and from my understanding the bus clock is 40,000,000hz. So if I want a 4M baud rate, I compute I need a divisor of 5, but the_mcf5xxx_qspi_find_baudrate() function computes a divisor of 10 when I pass in bus clock speed of 40Mhz and 4M baud rate.



What am I missing?