Loading...
Pages: [1]   Go Down
Author Topic: Multithreading with Arduino Uno/Mega  (Read 1352 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All,

Multithreading / multitasking in general is very useful. You can run multiple things 'simultaneously' while keeping your code nicely seperated (no spaghetti code).
I have attached a working example (I compiled with toolchain of Atmel Studio 6).

It runs two threads, prints out something over serial connection and blinks the onboard led. It uses AtomThreads (http://atomthreads.com/). It uses a preemptive schedular (apparently).
NOTICE: AtMega2560 has port 7 tied to the on board led instead of port 5. (So change PORTB ^= (1 << 5); to PORTB ^= (1 << 7); for arduino mega).

Hopefully someone finds this useful.

Cheers.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

that's very interesting.

Thanks for sharing!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just started looking into multi-threading when I stumbled upon your post. Thanks for sharing! Will give it a shot with my Mega.

Only downside is that the Atmel Studio runs on a Windows platform and I just got comfortable using the Arduino IDE on my OSX smiley No big deal tho.
Logged

0
Offline Offline
Edison Member
*
Karma: 6
Posts: 1399
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Why would you use multi-threading on Arduino?
Do you see a practical application for it?
Logged

Pages: [1]   Go Up
Print
 
Jump to: