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
Posted: Mon Oct 05, 2009 4:58 am
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;
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