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

Two interrupt problems

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



Joined: 22 May 2008
Posts: 63
Location: Madison, TN

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

Two interrupt problems
PostPosted: Mon May 07, 2012 9:08 pm     Reply with quote

Two problems (Version 4.130)
First:
I have a short nonsense program where this compiles
Code:

#INT_timer0   //
void EnableLines() {    //
  bCActive = rEnC;
}

but this produces the error
Error 7 "SpiTest.c" Line 125(9,10): Invalid Pre-Processor directive
Code:

#INT_RA   //   ONLY CHANGE IS TIMER0 TO RA
void EnableLines() {    //
  bCActive = rEnC;
}   

Why the error? How do I get rid of it?

Second:
Port A will actually have three independent pins interrupting on a high to low change. My reading the PICC manual and the 16F1828 manual leave me perplexed. As I see it I have to enable each of them like this
Enable_Interrupts (INT_RA1_H2L | INT_RA2_H2L | INT_RA3_H2L); Then within the int routine what's the best way to separate them? Do I have to test the individual bits of the interrupt register?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 07, 2012 9:35 pm     Reply with quote

Always post a test program. I made one and it doesn't fail:
Quote:

Build Successful.
Loaded C:\Program Files\PICC\Projects\PCM_Test\PCM_TEST.cof.
BUILD SUCCEEDED: Mon May 07 20:35:24 2012

CCS PCM C Compiler, Version 4.130, xxxxx 07-May-12 20:35

Code:

#include <16F1828.H>
#fuses INTRC_IO, NOWDT
#use delay(clock=4M)

int8 bCActive;
int8 rEnC;

#INT_RA   
void EnableLines() {     
  bCActive = rEnC;
}   

//==================================
void main()
{


while(1);
}
SuperDave



Joined: 22 May 2008
Posts: 63
Location: Madison, TN

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

PostPosted: Tue May 08, 2012 6:26 am     Reply with quote

OK, thanks, late night typo was the problem. My include spec'd a 16F1826, not 1828 the correct part. The 1826 doesn't allow RA.

So, now the second problem restated. The 16F1828.h file includes these two lines one after the other
Code:

#define INT_RA                    0x30FF0B08
#define INT_RA0                   0x30010B08

This compiles
Code:

#INT_RA      //port A change interrupt handler
void MyTestPgm() (
  //stuff
}

This doesn't
Code:

#int_RA0   //port A bit0
void MyTestPgm() (
  //stuff
}

I sort of get it that the two seem to be used differently even though they are in the same section of the include. So I use RA0 in the enable_int and RA to identify the interrupt handler. But if I want multiple bits from Port A, what is the best way to separate them in the handler? Nothing I find seems to deal with that.

Thanks again,
Dave
temtronic



Joined: 01 Jul 2010
Posts: 9250
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue May 08, 2012 9:56 am     Reply with quote

Dave, 'somewhere' maybe the onscreen help files ?, CCS shows how to access individual bits of PORTB high nibble (b7..b4).
That code does work, I've used it on several projects.
hth
jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 08, 2012 5:58 pm     Reply with quote

Quote:

This compiles

#INT_RA
void MyTestPgm() (
//stuff
}

That's the correct way to invoke the #INT_RA interrupt.


Ttelmah's post shows how to enable interrupts for multiple pins:
http://www.ccsinfo.com/forum/viewtopic.php?t=45432&start=6
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