Jump to content
Nytro

C bit field structures for microcontroller multitasking

Recommended Posts

Posted

C bit field structures for microcontroller multitasking

posted Nov 22nd 2011 9:01am by Mike Szczys

filed under: Microcontrollers

bit-field-tutorial.jpg?w=470&h=263

So you’re getting better at programming microcontrollers and now you want to do several things at once? You know better than that, microcontrollers are only capable of processing one thing at a time. But if you’re clever with your coding you can achieve something that behaves as if several things are going on at once. The most common way to do this is to set a flag using an interrupt, then use the main loop to check for that flag. [s1axter] posted a tutorial on this topic where he uses bit field structures to help simplify time sensitive events.

We think [s1axter] did a fantastic job of explaining this moderately difficult topic clearly and quickly. In the video after the break he begins by explaining what a bit field is and how it is defined. Basically you’re using a C structure to track a flag using just one bit of storage. This way the flag is either set or not. We suggest you pay careful attention to how he declares the structures as volatile, so you don’t have unexpected behavior when you try it yourself.

Video:

http://www.youtube.com/watch?v=Voqg4Mx2Sg8&feature=player_embedded#!

Sursa: http://hackaday.com/2011/11/22/c-bit-field-structures-for-microcontroller-multitasking/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...