SPI: speed calculation

Nov 18, 2004 5 Replies

Hello, All!



I'd like to get speed of 500 Kbit/sec by SPI communication. I don't quite understand how can I calculate the clock frequency to adjust to this value? Could you please explain. I'm using ATmega162.



Thank you.



With best regards, Roman Mashak. E-mail: snipped-for-privacy@tusur.ru


Did you look at Table 68 of the datasheet?

Hello, Gary! You wrote on 18 Nov 2004 06:12:29 GMT:

??>> I'd like to get speed of 500 Kbit/sec by SPI communication. I don't ??>> quite understand how can I calculate the clock frequency to adjust to ??>> this value? Could you please explain. I'm using ATmega162.

GK> Did you look at Table 68 of the datasheet? yes, of course but it didn't explain to me how is _speed_ calculated according to frequency value. That's why I asked here, i understand it's a question of math and brains :) but nevertheless....

With best regards, Roman Mashak. E-mail: snipped-for-privacy@tusur.ru

to

Well, ehhhr, speed in bits per second equals the frequency of SCK....

Meindert

You're probably over-thinking this. It's pretty simple. A bit is sent for every clock pulse. If you want 500Kbit/sec, then you send clock pulses at the same rate of 500K pulses/sec. You then need to find out how much you need to divide the clock of the ATMega162 to achieve that result and set the bits according to that table.

However, you must remember that the major influence in 'actual' throughput will depend on how fast your code loads the transmit buffer on each byte to send.

PhilW

a

the

to

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required