MController NewBie - About Timers & Interrupts & Sim

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. I want to run several tasks at the same time on my embedded system + i wont use any embedded linux kernel etc which supplies a logical threading system...

What are my ways ? How should i use timers & interrupts on my AVR ?

2. For electronics projects i've used Proteus , and i found 3 samples with AVR in Proteus 6.9 SP4 , is it stable to simulate avr hex with proteus ?
If not , can u give me advices about simulating AVRs ?

( I will use Atmega128L )

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One solution. Write yours 'threads' as infinite loops in the main program.
Use a variable that is decremented to zero by a timer interrupt. Check this value at the end of each loop, and when the value is zero, set the new value (as time for the next loop) and jump to the next loop. If the value is not zero, repeat the actual loop. Repeat this infinitely.
Switching between threads from fixed locations, your stack will be empty each time you swich the thread.
You can set diferent times for threads.
Be careful with interrupts.
Jobs like keyboard inputs, do via interrupts, because can freeze all the others threads. Is your decision, depending on the case, if something is better to be done via by interrupt or via by thread.
As you see, many limitations.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As you said i wont use interrupts except critical tasks....

So the only way ( without an embedded linux etc ) is arranging timers in my Main function ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

akhin wrote:
2. For electronics projects i've used Proteus

IMHO Proteus 6.9 SP4 is supper tool not only for AVR !

Ypu can simulate not only hex but с source bu means of .cof files

try \Proteus 6 Professional\SAMPLES\One-Wire\NETWORK\

1WIRE_NET.DSN

It's 1-wire network in CodeVisionAVR C with powerfull simulation options and many dallas-maxim 1-wire ic's.