CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

purpose of spi_data_in(); and SSP ISR

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gokulrred



Joined: 22 Nov 2011
Posts: 32
Location: puducherry

View user's profile Send private message Send e-mail

purpose of spi_data_in(); and SSP ISR
PostPosted: Fri Jan 13, 2012 6:49 pm     Reply with quote

SSP ISR can be used when SPI data is sent to slave from master.

during that time interrupt will be generated and SSP ISR is called and we can read SPI data using spi_read(); in SSP ISR.
i have no doubt in this.

spi_data_in();

Function:
Returns TRUE if data has been received over the SPI.

Example:

if( spi_data_is_in() )
data = spi_read();


here.........................
Can we write the above in main and use instead of SSP ISR????//

For example:
I am using SSP ISR for reading.
Instead can i use the above in main itself and so that whenever data comes will it automatically read at any time?
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jan 13, 2012 7:17 pm     Reply with quote

The purpose of an ISR, any ISR, is to 'flag' or inform the 'main' program that 'something' important has occoured, stop whatever you're doing, take appropriate action to that 'flag', then carry on in 'main' doing whatever you were doing before the interrupt happened.

The ISR is a fast,efficient way to program.

Without ISRs, you have to 'poll' or check to see if 'something ' has occoured.This requires a very tight loop or you could miss the 'something' from happening.
It's usually not a problem for say one or two switches, but having to poll say 8 switches, the serial port,check the LCD,etc. takes a LOT of time and you WILL miss something.

There was a great comparison to checking for mail in the mailbox a few days ago, it's well worth reading !
gokulrred



Joined: 22 Nov 2011
Posts: 32
Location: puducherry

View user's profile Send private message Send e-mail

PostPosted: Fri Jan 13, 2012 7:45 pm     Reply with quote

thank you for ur active and rapid answer...

so spi_data_in will not interrupt but we can read data throu that....
right?????
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Sat Jan 14, 2012 4:17 am     Reply with quote

The PIC hardware peripherals like SPI often do several things. One is they set a flag and two they with post a register and three if given permission to interrupt they will jump to your ISR. The spI data is in is testing the flag that the hardware set when it posted the register with the new data. Without an interrupt the main code must retrieve the value from the hardware register before it is overwritten with new data or that it overflows. This means the main code must have a short loop that varies with the processor speed.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group