I'm trying to create a high speed clock ( sub-us) line that I'm manually toggling high and low.
I'd like to use something like the following code to utilized digitialWriteFast and have flexibility to change the pins being used by changing a constant.
Unfortunately the compiler is optimizing the 2 writes out of the code. Call delayMicroseconds(1) instead of the asm nop's the digitalWrites aren't optimized out.
Does anyone know of a way to prevent the compiler from optimizing out the digitialWriteFast calls so that the resulting code looks like
OK, I figured out the issue. There is a bug in the digitWriteFast code. Basically the first parameter to bitWrite needed to have a volatile cast on it which is missing. I determined this by looking at the wiring and avr/sfr_defs code.
I've changed the atomicWrite to add the volatile uint8_t cast and removed the uint8_t cast from the fast macro. Everything is happy now