can sombody shed some light on this as i am not sure how to do it.
i have a call to use two interupt routines both on key presses
the first one is to exit a setup / test page after a time say 1 min if a key is not pressed
the second one is to turn off the lcd display back lighting after say two mins if a key is not pressed but turn it back on if any key is pressed
any tips or examples please
Ta steve
interupts
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: interupts
Hello Steve,
You will have to use a timer interrupt with as low an interrupt rate as possible to allow for periods of 1 and 2 minutes to be recorded. Your count variable will also have to be an INT type variable.
Create a timer interrupt that increments a variable. In your main program clear the count variable when a key is pressed. Test the count variable in your program and if it goes above a certain value eg 60 x number of interrupts per second then you know the timeout has occurred and you can exit back to say your main screen.the first one is to exit a setup / test page after a time say 1 min if a key is not pressed
again your count variable will come in here. if the count is less then 120 x number of interrupts then switch on backlight otherwise switch off backlight.the second one is to turn off the lcd display back lighting after say two mins if a key is not pressed but turn it back on if any key is pressed
You will have to use a timer interrupt with as low an interrupt rate as possible to allow for periods of 1 and 2 minutes to be recorded. Your count variable will also have to be an INT type variable.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
Steve001
- Valued Contributor

- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: interupts
i have some questions on interuptts if somebody can help me..
Its a long time since i have used them (BBC Micro days)
do they work like maskable and non maskable interuptts? as my program is working away, it will react then go and do something else then jump back.
can i call multiple interuptts in the same macro ?
eg: using a TMR0 and a Port interuptts ?
if i am waiting for TMR0 to time out (2 mins delay) will my program still be running in the background?
steve
Its a long time since i have used them (BBC Micro days)
do they work like maskable and non maskable interuptts? as my program is working away, it will react then go and do something else then jump back.
can i call multiple interuptts in the same macro ?
eg: using a TMR0 and a Port interuptts ?
if i am waiting for TMR0 to time out (2 mins delay) will my program still be running in the background?
steve
Success always occurs in private and failure in full view.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: interupts
I believe Timer0 is non-maskable.Steve001 wrote:do they work like maskable and non maskable interuptts? as my program is working away, it will react then go and do something else then jump back.
When Timer0 times out, it will pause main main routine jump into interrupt routine, then jump back to where it was paused from.
Not 100% sure if reading correctly .Steve001 wrote:can i call multiple interuptts in the same macro ?
eg: using a TMR0 and a Port interuptts ?
Manually calling an interrupt macro, or calling a interrupt form within a interrupt was defiantly be a mistake.
Also do not place delays, or any components that contains delays e.g LCD Components within interrupt macro.
It will cause all sorts of corruption.
Defintly yes. Your progam will still be running in the background.Steve001 wrote:if i am waiting for TMR0 to time out (2 mins delay) will my program still be running in the background?
Don't forget, depending on the interrupt frequency, interrupt macro will be accessed fairly quickly (but access time is very long compared with how fast you main program will be running) and left very quickly . Your program will be running in the background for the rest of the time.
Hope this helps.
Martin
-
Steve001
- Valued Contributor

- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: interupts
thanks for that . giving flowcode a break for a while . my head is in bits with this i know what i want it to do but it's not happining and i am getting stressed with it
will let you know how i get on when i have another go
steve
will let you know how i get on when i have another go
steve
Success always occurs in private and failure in full view.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: interupts
It could just be a ether a simple matter of configuration.
Either your config settings, or with timer0 interrupt you have the default 'Transition on T0CKI Pin' instead of 'internal clock' selected.
When you decide to go back onto Flowcode, its better to post flowchart, and ask for help than to get stressed with it.
We are here to help.
Either your config settings, or with timer0 interrupt you have the default 'Transition on T0CKI Pin' instead of 'internal clock' selected.
When you decide to go back onto Flowcode, its better to post flowchart, and ask for help than to get stressed with it.
We are here to help.
Martin
Re: interupts
This has been a useful thread for me, I look forward to steve posting his example so I can pick up on this topic....
Carl
Carl
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: interupts
Hi Steve.
Until I know what your target device and oscillator speed, and if internal or external, I will use 16F88 and 19.6MHz.
This Flowchart does not use interrupts for the switch detection, but uses interrupts for the backlight off timing after 120 Secs and Setup Mode exit after 60secs of no key press.
If you want to use interrupts for key press detection, then you will need to state a different target device. Reason being LCD will only work on portB of 16F88. But port interrupt also only works with portB.
So for 16F88 I have placed key input within timer0 interrupt.
At least you have a starting point.
If you are still having problems with files getting corrupt, then I will forward flowchart via email.
when you fist run program, you will see on LCD the seconds count from 0. and backlight (LED on Port A4) is on. If you leave for 2 mins then backlight will go off.
Press Setup Key (connected to A0) to go in to Setup mode. In setup mode, if you don't press Key2 (connected to port A1) after 60 secs wil exit.
Every time you press Key2 in normal or setup mode, seconds will reset to 0.
Hope this helps you.
Until I know what your target device and oscillator speed, and if internal or external, I will use 16F88 and 19.6MHz.
This Flowchart does not use interrupts for the switch detection, but uses interrupts for the backlight off timing after 120 Secs and Setup Mode exit after 60secs of no key press.
If you want to use interrupts for key press detection, then you will need to state a different target device. Reason being LCD will only work on portB of 16F88. But port interrupt also only works with portB.
So for 16F88 I have placed key input within timer0 interrupt.
At least you have a starting point.
If you are still having problems with files getting corrupt, then I will forward flowchart via email.
when you fist run program, you will see on LCD the seconds count from 0. and backlight (LED on Port A4) is on. If you leave for 2 mins then backlight will go off.
Press Setup Key (connected to A0) to go in to Setup mode. In setup mode, if you don't press Key2 (connected to port A1) after 60 secs wil exit.
Every time you press Key2 in normal or setup mode, seconds will reset to 0.
Hope this helps you.
- Attachments
-
- Backlight Control RevA.fcf
- (15.14 KiB) Downloaded 321 times
Martin