View previous topic :: View next topic |
Author |
Message |
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
Interrupt on change |
Posted: Mon Feb 12, 2018 10:17 am |
|
|
I'm using a 12LF1552, v5.075 compiler. What does constant INT_IOC do when used with enable/disable_interrupts?
It sets bits that are not used in any other INT_IOC_XXX define. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Mon Feb 12, 2018 10:34 am |
|
|
You should post a small, compilable program that shows what you're asking. That will allow us to compile and test on our computers as well as dump the listing.
If you dump the listing , you can easily see which bits of what registers are being set or cleared. Consulting the datasheet section that has IOC info and the PIC device header will show what's going on and why. |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Mon Feb 12, 2018 11:02 am |
|
|
I want to use the interrupt-on-change feature with pins A0 & A1. I'm not following what file instructions ANDWF and IORWF are acting on.
Here's the listing for both:
Code: |
.................... clear_interrupt(INT_IOC_A1 | INT_IOC_A0);
0261: MOVLW FC
0262: MOVLB 07
0263: ANDWF 13,F
=======================================================================
.................... clear_interrupt(INT_IOC);
0261: BCF 0B.0
=======================================================================
.................... enable_interrupts(INT_IOC_A1 | INT_IOC_A0 );
00FC: BSF 0B.3
00FD: MOVLW 03
00FE: MOVLB 07
00FF: IORWF 11,F
0100: IORWF 12,F
=======================================================================
.................... enable_interrupts(INT_IOC);
00FC: BSF 0B.3
00FD: MOVLW FF
00FE: MOVLB 07
00FF: IORWF 11,F
0100: IORWF 12,F
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Mon Feb 12, 2018 11:08 am |
|
|
It enables _all_ the IOC bits.
So '0xFF' into the mask, while the others just enable the bits they specify. |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Mon Feb 12, 2018 11:29 am |
|
|
The datasheet has a note in paragraph 7.6, that says "The IOCIF Flag is read-only and cleared when all the interrupt-on-change flags in the IOCBF register have been cleared by software."
Yet, a search for IOCBF only finds one result, in the note I just quoted. There is no register definition for IOCBF.
When using INT_IOC in clear_interrupt(), it only clears the IOCIF bit in INTCON register, not all flags in the IOCBF register, where ever that is. Using INT_IOC_A1 | INT_IOC_A0 seems to do more.
So, is using INT_IOC sufficient to use for clearing IOC interrupts? It looks to me like it's not. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 12, 2018 11:37 am |
|
|
Clearly a copy-and-paste job by the techwriter at Microchip. |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Mon Feb 12, 2018 11:42 am |
|
|
It just occurred to me that the note I quoted in my previous post says the IOICF is "read-only". Yet, clear_interrupt(INT_IOC) writes to the IOCIF bit.
Is the datasheet in error, or is the compiler in error? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Mon Feb 12, 2018 3:21 pm |
|
|
this..
Quote: | Yet, a search for IOCBF only finds one result, in the note I just quoted. There is no register definition for IOCBF. |
IOCBF should probably be IOCAF.
I'm thinking a quick copy/paste from a PIC that has IOC on port B and this PIC only has port A.
IOC is a relatively new feature, well to me anyway. |
|
|
|