Interrupt on change

Enhanced mid-range devices. PIC12F1xxx and PIC16F1xxx

Interrupt on change

Postby jtemples » Tue Aug 09, 2016 7:38 pm

I've been working with interrupt on change on the PIC16F1777. The data sheet says, "In order to ensure that no detected edge is lost while clearing flags, only AND operations masking out known changed bits should be performed." Does that mean there's actually special silicon related to the AND instruction that avoids the race condition when clearing flags? The data sheet doesn't say that explicitly, and in the general case, an AND isn't going to do anything special to avoid clearing flags that shouldn't be cleared.
jtemples
Verified identity
 
Posts: 195
Joined: Sun May 25, 2014 2:23 am
Location: The 805
PIC experience: Professional 5+ years with MCHP products

Re: Interrupt on change

Postby NorthGuy » Wed Aug 10, 2016 3:49 am

I don't understand this. I always thought that all the operations are implemented as RMW, in which case it is absolutely impossible to clear other bits without any risk, but may be AND is different. It is possible to test.
User avatar
NorthGuy
Verified identity
 
Posts: 17
Joined: Sat Jul 30, 2016 3:08 am
PIC experience: Professional 2-5 years with MCHP products

Re: Interrupt on change

Postby ric » Wed Aug 10, 2016 4:27 am

Looking at Figure 13-1
The latches top left are reset on Q2 if the matching IOCAF bit is already set.

The IOCAFx latch only gets set on Q1 or Q4.
I would guess the AND operation is taking place on Q3, avoiding the race condition.

ioc.gif
ioc.gif (22.54 KiB) Viewed 5608 times
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Interrupt on change

Postby jtemples » Wed Aug 10, 2016 8:08 am

That makes sense, since Q3 is the "modify" cycle.

The example code for clearing is also a bit puzzling:

Code: Select all
MOVLW 0xFF
XORWF IOCAF, W
ANDWF IOCAF, F

Wouldn't COMF IOCAF, W accomplish the same function as the first two instructions?
jtemples
Verified identity
 
Posts: 195
Joined: Sun May 25, 2014 2:23 am
Location: The 805
PIC experience: Professional 5+ years with MCHP products

Re: Interrupt on change

Postby ric » Wed Aug 10, 2016 2:41 pm

jtemples wrote:Wouldn't COMF IOCAF, W accomplish the same function as the first two instructions?

I think you're most likely right. :)
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Interrupt on change

Postby NorthGuy » Wed Aug 10, 2016 4:24 pm

If it works as ric described, then everything is taken care of in hardware, and it does make perfect sense. I don't see any reason why AND or any other particular instruction should be used. BCF should work just as well.
User avatar
NorthGuy
Verified identity
 
Posts: 17
Joined: Sat Jul 30, 2016 3:08 am
PIC experience: Professional 2-5 years with MCHP products


Return to 14-Bit Core (enhanced)

Who is online

Users browsing this forum: No registered users and 3 guests

cron