Jump to content
Sign in to follow this  
cromiumlake

Timer order

Recommended Posts

Hi there,

 

 

Is there any specific order on which TACTL should be configured?, what I mean is:

 

TACTL = MC_1|ID_3|TASSEL_2|TACLR;

 

TACLR always at the end, I guess not but no sure

Share this post


Link to post
Share on other sites

It makes no difference at all since those symbols are just C "#define" macros which boil down to numbers, and those numbers are OR'd together by the compiler before the final instructions are generated.

 

So the CPU just sees a memory location getting a single number written to it with the specified bits set.

 

Sent from my Galaxy Note II with Tapatalk

 

 

Share this post


Link to post
Share on other sites

There is no requirement for the order; I prefer to list values in the same order they appear in the user's guide bitfield definitions, which has MSB to the left.  This makes it more clear when a bit flag is being left out intentionally.  Thus:

TACTL = TASSEL_2|ID_3|MC_1|TACLR;

or

TACTL = TASSEL__SMCLK | ID__8 | MC__UP | TACLR;

if you're using an MCU where the header provides the more evocative symbols and don't have to worry about supporting the processors where these defines are missing.

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

×
×
  • Create New...