I no longer even KNOW what us old-farts are even arguing about :-)
All I CAN say is that if we come 'in' with PORTA_PCR13 as 0x00_04_01_77 (underscores are mine, of course) THEN
PORTA_PCR13 = (PORTA_PCR13 & ~PORT_PCR_IRQC_MASK) | PORT_PCR_IRQC(0xA);
will make it into 0x00_0A_01_77 by clearing the appropriate nibble, then 'popping in' the 'A' there (falling edge mode), while
PORTA_PCR13 = PORT_PCR_IRQC(0x0);
will make it all zero 0x00_00_00_00, disabling the pin (etc).
What the compiler can 'optimize away' is 'limited', at LEAST in this case, by the declaration of this (and MOST chip registers) as VOLATILE.
It is indeed worth re-iterating here an earlier warning about 'clearing control bits' using this kind of read-modify-write. That is, IF this 'read' shows an active interrupt ISF, as in 0x01 in the first byte, THEN leaving that bit as a 'one' in your write-back WILL clear the interrupt on you, presumably 'unhandled'. These 'write one to clear' register bits are especially tricky for that, and even Freescale boiler-plate code falls victim to it at times. Other register-flag bits (in other contexts) can be cleared SIMPLY by 'reading'... Finding such a 'very rare fault' that hits right in the 'problem window' is irritating indeed.
So what this 'enable' statement would REALLY need to be is:
PORTA_PCR13 = (PORTA_PCR13 & ~(PORT_PCR_IRQC_MASK | PORT_PCR_ISF_MASK)) | PORT_PCR_IRQC(0xA);
so that we 'and off' a potential interrupt-status-indication as well.
Just to put the 'final nail' in this thing, this is a debug-listing/trace with added annotations:
| PORTA_PCR13 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK ; | // Initialize PCR |
| 0x424a: 0xf8df 0x093c | LDR.W R1, ??DataTable76_16 | ; PORTA_PORTA_PCR13 32bit constants are loaded PC-relative |
| 0x424e: 0xf240 0x1143 | MOVW R0, #323 | ; 0x143 ;Short constant, in instruction |
| 0x4252: 0x6001 | STR R0, [R1] | |
| PORTA_PCR13 = (PORTA_PCR13 & ~(PORT_PCR_IRQC_MASK | PORT_PCR_ISF_MASK)) | PORT_PCR_IRQC(0xA); | //ENABLE PIN INTERRUPT | |
| 0x424e: 0xf8df 0x0938 | LDR.W R0, ??DataTable76_17 | ; 0xfef0ffff (-17760257) This is our combined mask. |
| 0x4252: 0x680a | LDR R2, [R1] | ;Fetch port for RMW. R2=0x143 |
| 0x4258: 0x4002 | ANDS R2, R2, R0 | ;Clear the IRQC bits, avoid ISF |
| 0x425a: 0xf442 0x2220 | ORR.W R2, R2, #655360 | ; 0xa0000 ;'simple' constant, fits in instruction R2=0x000A_0143 |
| 0x425e: 0x600a | STR R2, [R1] | ; and finally the write-back |
| PORTA_PCR13 &= ~(PORT_PCR_IRQC_MASK | PORT_PCR_ISF_MASK); | //DISABLE PIN INTERRUPT | |
| 0x4260: 0x680a | LDR R2, [R1] | |
| 0x4266: 0x4010 | ANDS R0, R0, R2 | ;This RMW just clears bits |
| 0x4268: 0x6008 | STR R0, [R1] | ;R0 = 0x143 |
| PORTA_PCR13 = PORT_PCR_IRQC(0); | //CLEARS PCR | |
| 0x426a: 0x2000 | MOVS R0, #0 | |
| 0x426c: 0x6008 | STR R0, [R1] | ; The simple 'assignment only' to ALL ZERO |