View previous topic :: View next topic |
Author |
Message |
Mat.lk. Guest
|
event driven programming on MCU |
Posted: Wed Feb 21, 2007 7:20 am |
|
|
Hello.
I was wondering if someone of you guys is using the event driven programming for mcu program design.
If so, please give me some links/advice. |
|
![](templates/subSilver/images/spacer.gif) |
KaraMuraT
Joined: 16 May 2006 Posts: 65 Location: Ankara/Turkey
|
|
Posted: Wed Feb 21, 2007 7:48 am |
|
|
Could you be more specific? For example what do you want to do? _________________ /// KMT
/// www.muratursavas.com |
|
![](templates/subSilver/images/spacer.gif) |
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Wed Feb 21, 2007 8:10 am |
|
|
The closest thing to event driven i write is an infinite loop that checks if a certain flag is set to true, and if it is it runs appropriate code.
Thats as complex as I want to go for PICs for event driven stuff.
i.e.
Code: |
while(1)
{
if (flag1)
run_event_1();
if (flag2)
run_event_2();
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
davekelly
Joined: 04 Oct 2006 Posts: 53 Location: Berkshire, England
|
|
Posted: Wed Feb 21, 2007 8:19 am |
|
|
grasspuddle wrote: | The closest thing to event driven i write is an infinite loop that checks if a certain flag is set to true, and if it is it runs appropriate code.
Thats as complex as I want to go for PICs for event driven stuff.
i.e.
Code: |
while(1)
{
if (flag1)
run_event_1();
if (flag2)
run_event_2();
}
|
|
This is pretty standard practice, so long as you have some interrupt driven way of setting the flag (timer, serial etc).
Depends on your specific application, you might act on flags set in timer interrupts, or use a switch statement for commands from the serial port, or read external ports to decide the action. |
|
![](templates/subSilver/images/spacer.gif) |
Mat.lk. Guest
|
|
Posted: Wed Feb 21, 2007 9:31 am |
|
|
I have one project where i have to use the call handlers and gsm.
I have to make this thru event programming so i can use this logic on other hardware parts.
example:
detect incomming call
detect ring time in seconds
Code: | if (sec <10> 10){flag2; sec=0; } ?? |
Code: | #int_timerHandler
void timer0_isr()
{
i++;
if (i==100){
sec++;
i=0;
// i dont know what is with this text formating but each time when i make preview i get wrong formating
// here are 3 if's .. =, < , > then 10 sec.
}
}
void main()
{
enable_interrupts(int_timerHandler);
while(1)
{
if (flag1)
run_event_1();
if (flag2)
run_event_2();
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Mat.lk. Guest
|
|
Posted: Wed Feb 21, 2007 9:32 am |
|
|
Am asking this becuse i dont know how to start the second event and how to block the first ( by shutting down the whole timerHandler ? ) when the
call ringing time is longer then 10 seconds. In my case i need timer just to count the duration of the ringing so i guess i can make all this on the global (handler) part ? |
|
![](templates/subSilver/images/spacer.gif) |
|