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

#int_ssp is not working

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



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

#int_ssp is not working
PostPosted: Mon Oct 05, 2009 1:49 am     Reply with quote

Hi I am trying to get two PICs to communicate together with the SPI interrupt.

Code:

<code was completely wrong, removed! sorry for the inconvenience!>



Last edited by theteaman on Mon Oct 05, 2009 9:20 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 2:07 am     Reply with quote

Two examples:
http://www.ccsinfo.com/forum/viewtopic.php?t=39145
http://www.ccsinfo.com/forum/viewtopic.php?t=26888
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 3:11 am     Reply with quote

PCM programmer wrote:
Two examples:
http://www.ccsinfo.com/forum/viewtopic.php?t=39145
http://www.ccsinfo.com/forum/viewtopic.php?t=26888

thanks PCM programmer, however I have already seen these examples and from what I can see I am doing everything right.. I was hoping someone could see something wrong with my code above...
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 4:58 am     Reply with quote

You index (i) does not increment.
With your current setup you coluld get overrun in your buffer as you do not reset i until later on in main (after a 100us delay as well!) If even 1 char comes in after i = 4 before you set it back to 0 you would get corruption.

Try adding to your code.

Code:

int1 done = false;

#INT_SSP
void ssp_isr(void)
{
   buffer[i] = spi_read();
   if (i++ == 4)
   {
     i = 0;
     done = true;
    }
}

And in main change it
Code:

// change
//      while(i < 4); //wait until all characters are recieved by int_ssp
// To
    while(!done);
    done = false;
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