hello,i am a new user of free flowcode5 and i need help in a problem i have.
how can i run a background tast (like plinging a led) but the main flowchart will go
on with the rest of comands doing other thing but still checking( a swich) an input to stop
the background comand? Thank you all.
Best regards.
help with background task
Moderator: Benj
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: help with background task
Hi chanalex,
I've deleted your double post. In future, please only post your question once to one forum.
The way to get LED and even switch to work in the background while performing other tasks is to use interrupts,
You can use timer interrupt to switch LED on or off, since timer interrupt keeps triggering at a fixed frequency. When interrupt is triggered, the current code is temporarily halted and the timer interrupt macro is accessed, then when interrupt macro is completed, the program resumes from where is has left off.
You can use a port interrupt to temporarily halt the program and access port interrupt macro, the switch is read then the program resumes from where is has left off.
Take a look at:
http://www.matrixmultimedia.com/mmforum ... =36&t=6390
Its an excellent article by Sean on interrupts and how they are used.
Martin
I will see if I can post something basic for you to try in a little while.
I've deleted your double post. In future, please only post your question once to one forum.
The way to get LED and even switch to work in the background while performing other tasks is to use interrupts,
You can use timer interrupt to switch LED on or off, since timer interrupt keeps triggering at a fixed frequency. When interrupt is triggered, the current code is temporarily halted and the timer interrupt macro is accessed, then when interrupt macro is completed, the program resumes from where is has left off.
You can use a port interrupt to temporarily halt the program and access port interrupt macro, the switch is read then the program resumes from where is has left off.
Take a look at:
http://www.matrixmultimedia.com/mmforum ... =36&t=6390
Its an excellent article by Sean on interrupts and how they are used.
Martin
I will see if I can post something basic for you to try in a little while.
Martin
Re: help with background task
thanks for your post.
i will try interrupts and i will post if i came up with any problems.
also a small example whould be very helpfull.
have a nice day.
i will try interrupts and i will post if i came up with any problems.
also a small example whould be very helpfull.
have a nice day.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: help with background task
Here is a basic flowchart that continuously runs a program (Flash LED1 at 1Hz).
As soon as switch connected to B6 goes is activated ( from 0V to +5V )
Then LED2 will go on. When switch is released, LED2 will go off.
As you can see from the flowchart, both LED2 and Switch are not placed anywhere within Main loop, so it does not matter what part of main loop the program is at, the LED2 will still be triggered when switch is activated.
The configuration is assuming you are using 16F88 and external crystal of 19660800Hz (19.66MHz) If this is different, or your using the internal clock (INTRC):
Then setting must be changed in Build/Project Options menu.
There are more Flowcode examples including interrupts here:
http://www.matrixmultimedia.com/lc_index.php?p=18
Martin
As soon as switch connected to B6 goes is activated ( from 0V to +5V )
Then LED2 will go on. When switch is released, LED2 will go off.
As you can see from the flowchart, both LED2 and Switch are not placed anywhere within Main loop, so it does not matter what part of main loop the program is at, the LED2 will still be triggered when switch is activated.
The configuration is assuming you are using 16F88 and external crystal of 19660800Hz (19.66MHz) If this is different, or your using the internal clock (INTRC):
Then setting must be changed in Build/Project Options menu.
There are more Flowcode examples including interrupts here:
http://www.matrixmultimedia.com/lc_index.php?p=18
Martin
- Attachments
-
- Interrupt Control1.fcf
- (16 KiB) Downloaded 266 times
Martin
Re: help with background task
Hello!
thanks Martin! you were very helpfull! i fingered it out,it was very easy with your help.
nice forum guys and you are doing good jub!
thanks Martin! you were very helpfull! i fingered it out,it was very easy with your help.
nice forum guys and you are doing good jub!