Antonio L Benci wrote: > > I am trying, so far in vain, to write some code for a 12C509 device > which has to do the following (shown in pseudo C code): > > Power on Device Reset; > > main{ > TRISB(0b11111100); > CLEAR GPWU; CLEAR GPPU; > > switch (RESET_CAUSE()) { > case NORMAL_POWER_UP: GP0=0, GP1-1; > case MCLR_FROM_SLEEP: GP0=1, GP1-0; > case default: error_handle(); > } Your switch statement is always going to fall through to the default error_handle function. You need a "break" statement in each of the case levels: switch (RESET_CAUSE()) { case NORMAL_POWER_UP: GP0=0, GP1-1; break; case MCLR_FROM_SLEEP: GP0=1, GP1-0; break; case default: error_handle(); break; } The last break is not necessary but, unless you're really tight on code space, it's good to put it in for clarity. --Matt