View previous topic :: View next topic |
Author |
Message |
tedlarson
Joined: 03 Oct 2003 Posts: 13
|
CAN bus interrupts... |
Posted: Thu Jun 09, 2005 12:37 pm |
|
|
I have been fooling with CAN bus. I finally have some nice test programs written, that work well.
I am stuck trying to build an interrupt driven receive.....what is the easiest way to process the CAN interrupts? It appears that this stuff isn't built in the the CCS compiler yet.
Ideas?
Thanks,
-Ted |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 09, 2005 1:15 pm |
|
|
Quote: | It appears that this stuff isn't built in the the CCS compiler yet. |
I compiled the following program with PCH vs. 3.188, and checked the
.LST file. The compiler is generating the correct code.
Code: | #include <18F458.h>
#fuses XT, NOWDT, NOPROTECT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#int_canirx
void can_isr(void)
{
char c;
c = 0x55;
// Put in code to do the following:
// Test the RXB0IF and RXB1IF bits in the PIR3 register
// to see which buffer has received a new message.
// Then handle the message.
// Then clear the RXB0IF or RXB1IF bits (or both) in order
// to clear the interrupt condition.
}
//========================================
void main()
{
enable_interrupts(INT_CANIRX);
enable_interrupts(GLOBAL);
while(1);
} |
|
|
|
tedlarson
Joined: 03 Oct 2003 Posts: 13
|
|
Posted: Thu Jun 09, 2005 2:23 pm |
|
|
Thanks! I guess it helps to look at the device specific header file for the interrupts missing from the documentation. Looks like there are all kinds of nicely supported CAN interrupts in there. I feel slightly blind after reading the ECAN spec in the PIC18F2580 datasheet at this point.
Thanks for pulling my head out of the sand.
-Ted |
|
|
|