Jump to content

Recommended Posts

ok one more stupid question. using the given code, 1.0 and 1.1 are the control bits for the motor direction. got that. what I don't understand is what's actually happening with CCR1 and bit2. It seems based off the video and the code from the example that the lower CCR1 is, the faster the motor goes. but I think i'm missing something very fundamental. say for example, bit 1 and 0 are set to 1 and 0 respectively, what do I actually do to change the signal on 1.2 to turn the thing on or off?

Link to post
Share on other sites

Instead of manually turning motor on and off (when doing PWM that is,) I am using timer's feature.

CCR0 is the interval, CCR1 controls duty cycle. So for example, if CCR0 is 100, CCR1 close to 0 means motor is on for almost 100% of the time, when close to 100, motor is on for just a bit of time.

If you want to turn the motor off for good, you can disable P1.2 TA1 feature and set P1.2 manually to 0. Note that setting CCR1 to CCR0, will keep the PWM at 1 cycle, so the motor will never be totally on.

See 12.2.5 of the User's Guide, there you will find information about timer's output modes and how they work.


Basically, at the beginning, set P1.2 as output and set it to 0.

Setup everything else as you do except TA1 output. (P1SEL |= BIT2;)

Then when you ready to turn your motor on, set P1SEL bit2 to 1 and that will enable timer's TA1 output which will control motor's duty cycle.

Link to post
Share on other sites

alright. i'll keep giving it a try. I'm pretty sure all my hardware is just fine because occasionally the motor turns, it's just never turning when I want it to. I can get the select bits set just fine and checked em with my DMM, Just the 2nd bit is not doing what it needs to do and I can't figure it out. How much risk of burning stuff up am I gonna be if i just don't use PWM and set bit 2 to high when I want it on, and low when I don't?

Link to post
Share on other sites
  • 2 months later...

Ok i'm having a really interesting problem. Everything is wired up fine and my code is now fine, but for some reason, the motor doesn't start to turn until I start probing around with my multimeter. Once i do this, it starts working perfectly. I first thought it was maybe a short or loose connection but i've since eliminated that as a possibility. maybe capacitance across the MM? any ideas? i'm pretty stumped here.

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.

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...