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

Individual Interrupts on Port B

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



Joined: 10 Dec 2012
Posts: 2

View user's profile Send private message

Individual Interrupts on Port B
PostPosted: Mon Dec 10, 2012 9:52 pm     Reply with quote

I am using the 16LF1946 which allows individual interrupts on every Port B pin. There are defines in the device.h for each port pin to set positive (and/or) negative edge.

HOWEVER -- the compiler does not recognize the defined interrupts for individual pins to be used as isr locations (for example) #INT_RB2_H2L. In fact, I believe the only valid isr location is INT_RB which is the "general" interrupt for any change on the port.

What I've found is that you can define active edges for individual pins by doing individual enables for the desired pins. But using the "general" #INT_RB isr location then ruins the settings by setting all edges valid on all pins whenever you enable_interrupts(INT_RB).

Can you override this "feature" and actually ever enable just 3 or 4 pins on the port as interrupt on change with these supplied calls?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 10, 2012 11:32 pm     Reply with quote

Quote:
whenever you enable_interrupts(INT_RB).

If you want individual pin interrupts, I'm not sure why you are doing this.
The statement above will enable interrupts on positive and negative
edges for all pins on port B. You can see this in the .LST file:
Code:

.................... enable_interrupts(INT_RB);
001C:  BSF    INTCON.IOCIE
001D:  MOVLW  FF
001E:  MOVLB  07
001F:  IORWF  IOCBP,F
0020:  IORWF  IOCBN,F

Maybe it's a misunderstanding of how to do it. You should use #int_rb as
the isr. Then do individual pin enables as desired. The interrupts will
go to the #int_rb isr. You don't need to use enable_interrupts(INT_RB).

What's your CCS compiler version ? It's given at the top of the .LST file
which will be in your project directory after a successful compilation.
Example of version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Tue Dec 11, 2012 5:20 am     Reply with quote

I think the key 'error' is in the heading of the thread. "Individual interrupts on Port B". The chip does not support this. It supports _one_ interrupt only here. INT_RB. What you can have is individual _masking_ of the pins, and which direction they trigger this interrupt in. The enable_interrupt instruction, handles this. So:

enable_interrupts(INT_RB2_H2L);

sets up the masking, so the INT_RB interrupt is only triggered on this edge.

enable_interrupts(INT_RB2_H2L | INT_RB3);

will enable the interrupt to trigger on the high to low edge of RB2, and both edges on RB3.

Now, the chip sets separate flags in the IOCBF register, according to what bit actually triggered the interrupt. On some compiler versions (with varying degrees of success), CCS read this, and test the individual flags to then optionally vector you to separate handlers. Personally I'd say you are much better to do this yourself. Just have a single INT_RB, then read this register, and run the code for the input(s) you want (and remember to clear the bit when finished).

So, whether it will work with separate handlers is version dependant.

Best Wishes
lrw_eng



Joined: 10 Dec 2012
Posts: 2

View user's profile Send private message

PostPosted: Tue Dec 11, 2012 11:00 am     Reply with quote

Thanks to all for the clarifications.. The larger part of my confusion was whether making calls to enable INDIVIDUAL pins was taking care of the RBIE bit in the interrupt control register properly.. From the assembly listing above --- it is clear that it does.

So #INT_RB does all of the flag clearing for RBIE.. And I will set all the INDIVIDUAL flags to zero in the IOC flag reg anyway.

I'll post a listing in the other forum when I've got this working.

Thanks again...
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