EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Microchip PIC 18f8722 USART2 Interrupt Problem

Started by Unknown January 23, 2008
Hi,

Microchip PIC 18f8722 USART2 Interrupt is not working - I have USART1
working fine with interrupts but cannot get interrupt on usart2 - the
RC2IF interrupt flag never gets set although data is coming into the
rcreg2 register and i can read from it.

Is there any special considerations I need to take into account?
Global INT flag is enabled as well as all INTs on High priority.  Code
is exactly the same as that of usart1 but usart2 INT flag never gets
set?

Any help greatly appreciated!

Thanks,

GI.

On 2008-01-23, gary.ireland@ams-neve.com <gary.ireland@ams-neve.com> wrote:
> Microchip PIC 18f8722 USART2 Interrupt is not working - I have USART1 > working fine with interrupts but cannot get interrupt on usart2 - the > RC2IF interrupt flag never gets set although data is coming into the > rcreg2 register and i can read from it.
RC2IF is the only indication that data has been received in RCREG2, so why do you believe you are receiving data if RC2IF is not going high? -- John W. Temples, III
also posted to alt.microcontrollers.8bit
gary.ireland@ams-neve.com wrote:
> Hi, > > Microchip PIC 18f8722 USART2 Interrupt is not working - I have USART1 > working fine with interrupts but cannot get interrupt on usart2 - the > RC2IF interrupt flag never gets set although data is coming into the > rcreg2 register and i can read from it. > > Is there any special considerations I need to take into account? > Global INT flag is enabled as well as all INTs on High priority. Code > is exactly the same as that of usart1 but usart2 INT flag never gets > set?!
How do you know that the interrupt flag is not being set? Generally speaking, on PICs the interrupt flags are set regardless of whether the interrupt is enabled. IOW, RC2IF should get set when data arrives because there is nothing that you can configure to prevent it from happening. Do you have the RC2IE flag set? You have to have the peripheral interrupts enabled as well, but you must have or the other USART wouldn't be working. How about the priority level assignment in IPR3? IMO, the PIC is not seeing any data or you don't actually have the interrupt enabled. Generally speaking again, PICs will refuse to receive data on a USART if there is an error flag set such as "receive overrun" or "framing error". Either that or your problem lies in PIR3, PIE3, or IPR3.
On Jan 25, 6:41=A0pm, "Anthony Fremont" <nob...@noplace.net> wrote:
> also posted to alt.microcontrollers.8bit > > gary.irel...@ams-neve.com wrote: > > Hi, > > > Microchip PIC 18f8722 USART2 Interrupt is not working - I have USART1 > > working fine with interrupts but cannot get interrupt on usart2 - the > > RC2IF interrupt flag never gets set although data is coming into the > > rcreg2 register and i can read from it. > > > Is there any special considerations I need to take into account? > > Global INT flag is enabled as well as all INTs on High priority. =A0Code=
> > is exactly the same as that of usart1 but usart2 INT flag never gets > > set?! > > How do you know that the interrupt flag is not being set? =A0Generally > speaking, on PICs the interrupt flags are set regardless of whether the > interrupt is enabled. =A0IOW, RC2IF should get set when data arrives becau=
se
> there is nothing that you can configure to prevent it from happening. =A0D=
o
> you have the RC2IE flag set? =A0You have to have the peripheral interrupts=
> enabled as well, but you must have or the other USART wouldn't be working.=
> How about the priority level assignment in IPR3? > > IMO, the PIC is not seeing any data or you don't actually have the interru=
pt
> enabled. =A0Generally speaking again, PICs will refuse to receive data on =
a
> USART if there is an error flag set such as "receive overrun" or "framing > error". =A0Either that or your problem lies in PIR3, PIE3, or IPR3.
Another possibility is that there has been either a framing error or an overrun error. Once this has happened the flag no longer gets set until the error is cleared and/or the usart reset. See the datasheet. Rocky

Memfault Beyond the Launch