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 CCS Technical Support

Need to create new int to service PIR3 on 18F6680...HOW?

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



Joined: 16 Apr 2007
Posts: 26
Location: Arizona

View user's profile Send private message Visit poster's website

Need to create new int to service PIR3 on 18F6680...HOW?
PostPosted: Tue Sep 18, 2007 7:10 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Sep 18, 2007 7:47 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 19, 2007 1:39 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 19, 2007 2:58 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 19, 2007 9:48 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 19, 2007 10:14 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 21, 2011 5:09 am     Reply with quote

For author:
Maybe this link will help:
http://www.ccsinfo.com/forum/viewtopic.php?t=27060

For previous answer:
Have you tried using
Code:
#int_default
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