Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

SPI - Normal or Interrupt mode?

Status
Not open for further replies.
Hey there,

I managed to use the hardware SPI routines for the PIC 18F okay.

But which to use - Normal polling or Interrupt?

And must I use additional pull-ups for interfacing my 25LC640 EEPROM?
 
Well, I have no idea about the PIC specific hardware. but SPI isn't like a UART. If you are the Master, you don't have to keep checking if something is there. You only receive a value when you send one, so it's never a surprise.
 
But which to use - Normal polling or Interrupt?
It really depends upon the application. ie: Do you need to do something between sending/receiving bytes or can the PIC idle while waiting to send the next SPI byte?
 
Well, I have no idea about the PIC specific hardware. but SPI isn't like a UART. If you are the Master, you don't have to keep checking if something is there. You only receive a value when you send one, so it's never a surprise.

He didn't say internal or external clock. If the SPI's reading an external clock, then as a slave it's very possible to overrun the SPI module input buffer and underrun the output buffer. Usually not the case for an EEROM though, that communication would be PIC as a master.
 
Last edited:
If the SPI's reading an external clock, then as a slave it's very possible to overrun the SPI module input buffer and underrun the output buffer. Usually not the case for an EEROM though, that communication would be PIC as a master.

If you are the Master, you don't have to keep checking if something is there. You only receive a value when you send one, so it's never a surprise.

Yes, that's why I specified the master stuff. I could have done a better job explaining the alternative needed if it's a slave, but he mentioned the slave device in his post.
 
Last edited:
Oh sorry for forgetting to put some information inside.

The microcontroller will be the SPI master, at Oscillator/16, and everything else default which is read at middle, send on active edge.

I could use the basic routines for sending/receiving in SPI like:
Code:
unsigned char SPI(unsigned char d)
{
     SSPBUF = d;
     while(!SSPSTATbits.BF)
      return SSPBUF;
}

but I couldn't find any routines for the SPI based interrupt online. I only know how to turn on the SPI interrupts, and make it jump to the function when the SSPIF is raised, and afterwards, I get stuck there. :confused:

Any good pointers? Or must I just do a basic SPI routines without all the interrupts? Btw, I have two timers running at interrupt mode.
 
It seems like your question is more along the general line of "should I learn how to use interrupts?"

The answer is an unequivocal yes. As soon as possible. It doesn't matter much if this application needs it per se, you should learn how to do them right after learning basic "hello world" code writing and getting peripherals to turn on and do things.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top