|
|
View previous topic :: View next topic |
Author |
Message |
colinbrenton
Joined: 13 Feb 2007 Posts: 6
|
RDA_ISR causes SPI to fail |
Posted: Wed Feb 14, 2007 3:03 am |
|
|
Hi
This is my first post, be nice
I'm using an 18F452. with the hardware UART connected to a PC. The PIC also drives 5 of Maxim 6952 LED driver chips from the SPI bus. The problem I have is that when I include the RDA ISR, the SPI bus "locks". The effect is difficult to describe exactly, but prevents the displays from working correctly.
When the ISR is commented out, the SPI part works correctly.
Someone mentioned elsewhere that the ISR may be affecting the TRISC register, and to reset it before using SPI. Does this sound reasonable?
Attached is a sample program with the important information. The rest of the code is fairly mundane, string handling, delay loops etc...
Thanks in advance for any suggestions.
Colin
#include<18F452.h>
#include <string.h>
#include<stdio.h>
#include<spi.h>
#define _SPI_C
#define CS0 PIN_B0
#define CS1 PIN_B1
#define CS2 PIN_B2
#define CS3 PIN_B3
#define CS4 PIN_B4
#use delay(clock=4000000)
void main(void)
{ //code that uses SPI
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
for{;;}
{
.... //some other string handling stuff
SPI_WRITE(byte_value);
.... //some other string handling stuff
}
}
#int_RDA
RDA_isr()
{
Message[1]='Z';
} |
|
|
Ttelmah Guest
|
|
Posted: Wed Feb 14, 2007 3:56 am |
|
|
Big thing missing as posted, is any read of the incoming character in the RDA ISR.
Unless you read the character, the ISR will _permanently_ be called, and the chip will stop doing anything else.
Best Wishes |
|
|
colinbrenton
Joined: 13 Feb 2007 Posts: 6
|
|
Posted: Wed Feb 14, 2007 7:30 am |
|
|
Hi
Thanks for the reply. You are right of course, that was one of the things that didn't make it into the demo program that I posted. However it now appears to be working. I would include all the code, but it seems a bit excessive.
Thanks for the help. The actual ISR that does work is now
#int_RDA
RDA_isr()
{
setup_SPI(FALSE);
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, bits=8)
Message[place]=(getc());
putc(Message[place]);
place=place+1;
TempPlace=Place;
for (loop=TempPlace; loop<60; ++loop)
{
Message[loop]=' ';
}
Place=TempPlace;
//setup_UART(FALSE);
}
Thanks again for the help!
Best Regards
Colin |
|
|
|
|
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
|