View previous topic :: View next topic |
Author |
Message |
ChrisL
Joined: 16 Apr 2007 Posts: 26 Location: Arizona
|
Need to create new int to service PIR3 on 18F6680...HOW? |
Posted: Tue Sep 18, 2007 7:10 pm |
|
|
Hi All,
Working to finish the CAN J1939 conversion using interrupts. It does not appear (or I missed it) that there is an int to service PIR3 in the list of INTs for the PIC18F6680. Setting the bit in INTCON for PEIE is simple, but how do you code a service routine to manage that spicific interrupt...?
It would be great if anybody knows how CCS calculates the addresses that are in the device table. I would like to include it as a standard entry in the device table along with all the other INTs if possible. _________________ Thank you,
Chris |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 18, 2007 7:47 pm |
|
|
Version 4.056 of the compiler has the following values. I think these
are the ones you want.
Code: |
#define INT_CANIRX 0xA380
#define INT_CANWAKE 0xA340
#define INT_CANERR 0xA320
#define INT_CANTX2 0xA310
#define INT_CANTX1 0xA308
#define INT_CANTX0 0xA304
#define INT_CANRX1 0xA302
#define INT_CANRX0 0xA301
|
|
|
|
ChrisL
Joined: 16 Apr 2007 Posts: 26 Location: Arizona
|
|
Posted: Wed Sep 19, 2007 1:39 am |
|
|
PCM Programmer,
Here is the function we are trying to replace from PIC 18C Compiler;
Code: | #pragma code InterruptVectorLow = 0x0018
void InterruptVectorLow( void )
{
_asm
goto InterruptHandlerLow
_endasm
}
//--------------------------------------------------------------------
// Low priority interrupt routine
#pragma code
#pragma interruptlow InterruptHandlerLow
void InterruptHandlerLow( void )
{
if (PIR3 != 0x00)
J1939_ISR();
} |
I don't seem to be able to get any of the items in the list you provided to work..???? _________________ Thank you,
Chris |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Sep 19, 2007 2:58 am |
|
|
ChrisL wrote: | Code: | #pragma code InterruptVectorLow = 0x0018
void InterruptVectorLow( void )
{
_asm
goto InterruptHandlerLow
_endasm
}
//--------------------------------------------------------------------
// Low priority interrupt routine
#pragma code
#pragma interruptlow InterruptHandlerLow
void InterruptHandlerLow( void )
{
if (PIR3 != 0x00)
J1939_ISR();
} |
| CCS has a more advanced mechanism for creating interrupt handlers than the C18 compiler provides. The CCS compiler creates the interrupt dispatcher for you, saves all registers and clears the interrupt flag when you are finished. All you have to do is write the interrupt functions preceded by a #int_xxx keyword, where xxx is the name of the interrupt you want to handle.
I had a quick look at the C18 code from AN930 and it looks like for porting the code to CCS it is best to forget about the CCS way of handling interrupts. Very nice but the code is not written in a way that allows for an easy port. Luckily CCS provides a method for you to write your own dispatcher which is exactly what the C18 code does.
Replace the complete code fragment from above by: Code: | //--------------------------------------------------------------------
// Low priority interrupt routine
#int_global
void InterruptHandlerLow( void )
{
if (PIR3 != 0x00)
J1939_ISR();
} | Note that the InterruptVectorLow() function call is missing, the CCS compiler generates this for you implicitly. |
|
|
ChrisL
Joined: 16 Apr 2007 Posts: 26 Location: Arizona
|
|
Posted: Wed Sep 19, 2007 9:48 am |
|
|
ckielstra,
Thank you again for your help.
Do you know the method CCS uses to arrive at the addresses for the INTs that they create in the device profile that they publish. I would love to know the trick so that in the futrure we could create our own...! _________________ Thank you,
Chris |
|
|
ChrisL
Joined: 16 Apr 2007 Posts: 26 Location: Arizona
|
|
Posted: Wed Sep 19, 2007 10:14 am |
|
|
ckielstra,
Your code fragment:
Code: | #int_global
void InterruptVectorLow( void )
{
if (PIR3 != 0x00)
J1939_ISR();
} |
results in Quote: | Unprotected call in a #INT_GLOBAL
|
Any suggestions..? _________________ Thank you,
Chris |
|
|
dilandau
Joined: 25 Aug 2010 Posts: 11
|
|
|
|