Perhaps the method from Scott Dattalo is interesting, it is called vertical counters and I use it for almost all my projects. You need to call the function frequently (set up a timer interrupt with 1m ...
When running this code pin_c0 is high as expected until the putc('H') is executed. The trisc for pin c0 is then turned into an input and the bit for pin_c0 is reset. With the putc() line commen ...