EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

SPI: speed calculation

Started by Roman Mashak November 18, 2004
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: mrv@tusur.ru 


>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.
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: mrv@tusur.ru 


"Roman Mashak" <mrv@tusur.ru> wrote in message
news:cnhjj9$14u7$1@mpeks.tomsk.su...
> 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....
Well, ehhhr, speed in bits per second equals the frequency of SCK.... Meindert
> 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....
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


"Gary Kato" <garykato@aol.com> wrote in message
news:20041118034430.08355.00000847@mb-m04.aol.com...
> > 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.... > > 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. >

The 2024 Embedded Online Conference