Timer interrupts during SPI transfer

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I am building a system with an ATMEGA16, as SPI master and two peripheral devices. I need precise timing so I am thinking about using a CTC timer interrupt.

I am wondering whether this could work, because if the ATMEGA16 enters the timer's interrupt service routine will it be able to complete the SPI data transfer?

Any recommendations?

Thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Once you have written SPDR the transmission process will operate to completion whatever the code goes onto do (unless it sleeps so deeply that F_IO stops)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also, SPI is "static". That is, except at the upper end, clock widths are not important. So, if your software has to "stretch" some interval (usually between bytes), there is no real issue except for total transfer rate.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you very much.
I wanted to be that way. Guess I'm lucky!

Quote:
Once you have written SPDR the transmission process will operate to completion whatever the code goes onto do (unless it sleeps so deeply that F_IO stops)

Is this written somewhere in the datasheet?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Is this written somewhere in the datasheet?

Well the datasheet describes the operation of SPI - yes.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry I missed it!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is more implied than stated.

The SPI data is clocked in (and out) totally by hardware, much like a UART. The only software intervention is setup, load the data, and start the byte. Everything until the last bit is sent is automatic in hardware.

It is implied in the same way it is implied for timers. It never tells you, straight out, that other actions do not interfere with a timer count. The simple fact of how it is clocked should allow you to deduce that.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!