Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

quick interrupt question

Status
Not open for further replies.

evandude

New Member
Are interrupt flags updated even when GIE is cleared? IE- if I clear GIE for a short time while doing something in my program, and an interrupt event occurs during that time, when I set GIE again will the interrupt occur?

part of my program needs to constantly receive data packets from a PS/2 mouse, but it also needs to be outputting PWM on 4 separate channels at the same time. I have 4 values (0-12000) corresponding to 0-12mS, which are sorted into ascending order. I am using timer1 and the CCP module to generate an interrupt each time one of the 4 desired values is reached (then the next highest is loaded into it, the proper output is toggled, and it continues)

my problem is that there is no way that a PS/2 packet will be recieved properly if the PWM interrupt gets serviced during it. So I am hoping that I can clear GIE as soon as the PIC sees the start of a data packet, recieve the packet, and then set GIE as soon as that's done; granted, it will delay the PWM toggle, and so throw off the duty cycle somewhat
so my question, more specifically, is if there is supposed to be a level shift on one or more PWM outputs while the data packet is being received, once it is done and I set GIE again, will the CCP interrupt immediately occur?

(if you have any ideas for how to better handle the PWM generation, I'm interested in hearing that as well)

thanks in advance.
 
The flags are set regardless of the GIE bit, im not sure if it would interrupt if the flag is set and you enable, I always clear the flags before enabling so I never really cheacked..
 
The flags are set independently of the GIE or individual interrupt enable.

If you enable the interrupt, it will immediately involk the interrupt routine.

You don't always want to clear the flag before enabling. For example, I've got code in the main body which used data larger than 8 bit which gets updated in the interrupt routine. I must disable that interrupt while reading the data to ensure it's a single coherent snapshot, then immediately reenable it. If the interrupt has occurred in the meantime, its flag will be set and it will get handled automatically when reenabled.
 
Status
Not open for further replies.

Latest threads

Back
Top