I have the following snippet of code, which toggles one of the GPIO lines: PINSEL1 &= ~(0x0000000C); IO0SET |= MY_GPIO_MASK; IO0CLR |= MY_GPIO_MASK; PINSEL1 |= 0x00000008; This works fine as Thumb code at -O0. However, if I compile this as -O1 or higher (still Thumb), this code is optimized out and I don't get the "side effect" of my GPIO toggling. If I switch over to generating ARM code, this works at -O0, -O1, and -O2 (i.e. no problem). This seems really wrong. PINSEL1, IO0SET, etc. are all defined as volatile in LPC22xx.h, so shouldn't the compiler leave this alone when optimizing? Any good way of getting around this?
Can you please send a test project to support.intl@keil.com