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
toggle pin
-
siliconchip
- Posts: 31
- http://meble-kuchenne.info.pl
- Joined: Wed Dec 16, 2020 10:38 am
- Has thanked: 13 times
- Been thanked: 1 time
-
chipfryer27
- Valued Contributor
- Posts: 2022
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 444 times
- Been thanked: 665 times
Re: toggle pin
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
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