When setting compiler optimization to "Size", the outputs behave correctly.

When using CY_SYS_PINS_SET macros, the optimization does not have any impact and all works as intended.

IR1_DRV_Write and IR2_DRV_Write functions are auto-generated by PSOC creator:

void IR1_DRV_Write(uint8 value)

{

uint8 drVal = (uint8)(IR1_DRV_DR & (uint8)(~IR1_DRV_MASK));

drVal = (drVal | ((uint8)(value << IR1_DRV_SHIFT) & IR1_DRV_MASK));

IR1_DRV_DR = (uint32)drVal;

}

(The disassembly of IR1_DRV_Write and IR2_DRV_Write functions obviously are different with the two optimization levels mentioned. But I don't have the patience to go through the disassembly right now).

In the code snippet below I have commented the lines calling IR1_DRV_Write() and IR2_DRV_Write() functions.

Instead I put direct write to CY_PINS there which solved the problem.

Now the million dollar question is: Can I trust using the auto generated I/O support functions in PSOC creator?What if other I/O functions get more or less trashed by the various optimization levels?