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 support@ccsinfo.com

CAN bus interrupts...

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



Joined: 03 Oct 2003
Posts: 13

View user's profile Send private message

CAN bus interrupts...
PostPosted: Thu Jun 09, 2005 12:37 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jun 09, 2005 1:15 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jun 09, 2005 2:23 pm     Reply with quote

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
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