Page 1 of 1

toggle pin

Posted: Sun Jul 26, 2026 3:37 pm
by siliconchip
hi all
im working on toggling a port on and off, so far so good however im trying to use 2 switches so i can pick either of the frequencys i want that run for a predetermined time, the first runs as intended for 10 seconds at 40Hz,however when pressing the second swtch RA5 the software runs at the correct frequency of 52Hz but just keeps running instead of stopping at 15 seconds as intended, this has been tested on hardware, any feedback would be gratefully appreciated as to why it wont shut off after 15 seconds thanks in advance

Re: toggle pin

Posted: Sun Jul 26, 2026 3:56 pm
by chipfryer27
Hi

Not had time for a proper look but straight away there are concerns.

Interrupts should not be used as a functional "macro" so to speak. They should be as short as possible containing as little code as possible such as setting a "flag" for actioning in your Main loop or perhaps incrementing a counter which would again be actioned elsewhere depending on value.

I will try and have a better look later but as a start move all the decisions and processing out of your interrupt routine and into Main or other User Macro.

Regards