View Single Post
  #7   Spotlight this post!  
Unread 10-02-2008, 16:08
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: interrupt enable

Quote:
Originally Posted by 3dude_2231 View Post

aren't the 'IE's of kevin's code ISR in the GIEH?
No. And IEs are neither high or low in association - they just allow or disallow the associated interrupt from occuring.
The IP is what assigns the interrupt to high or low priority...

There are three things that control each interrupt, IP, IE, and IF.

Code:

. IP, Interrupt Priority - can be assigned to low or high if IPEN (interrupt 
      priority enable) is set which it should be.  The high priority interrupt
      handler is provided as part of the default code.  Assigning any peripheral
      interrupts to high priority should get the red-light-of-death as that
      interrupt handler won't check for or clear any interrupt its not expecting.
. IE, Interrupt Enable - enable an interrupt to occur if or when IF is set.
. IF, Interrupt Flag - the pin or device sets this flag when interrupt conditions
      are met.  The flag is set regardless of whether IE is on or off allowing
      code to poll for interrupt (request for service) conditions.
GIEH disables both high and low priority interrupts. GIEL enables/disables low prioriy interrupts. User's code should only assign interrupts to low priority.

The h/w logic for a low priority interrupt is something like;
Code:
if (GIEH && GIEL && (IPx=lo) && IEx && IFx) then interrupt processor...
There is one exception in Kevin's code base where he is setting up the local CCP hardware for PWM use - during the handful of lines that are setting up, the GIEH flag is used to disable all interrupts. But that is a one shot deal only done at setup. In all the other places I looked, the indivual IE is used to control specific interrups. As far as priority assignment, the following lines show that the interrupts are assigned to low priority.

Code:
interrupts.c:65: 	INTCON3bits.INT2IP = 0;		// 0: interrupt 1 is low priority (leave at 0 for IFI controllers)
interrupts.c:100: 	INTCON2bits.INT3IP = 0;		// 0: interrupt 2 is low priority (leave at 0 for IFI controllers)
interrupts.c:138:   	INTCON2bits.RBIP = 0;		// 0: interrupts 3-6 are low priority (leave at 0 for IFI controllers)
serial_ports.c:313: 	IPR1bits.RC1IP = 0;		// receive interrupt priority bit (must be 0 for IFI controllers) [130]
serial_ports.c:341: 	IPR1bits.TX1IP = 0;		// transmit interrupt priority bit (must be 0 for IFI controllers) [130]
serial_ports.c:497: 	IPR3bits.RC2IP = 0;		// receive interrupt priority bit (must be 0 for IFI controllers) [132]
serial_ports.c:526: 	IPR3bits.TX2IP = 0;		// transmit interrupt priority bit (must be 0 for IFI controllers) [132]

:
etc.