Jump to content
DomTech809

Enable PWM on Port 2 of MSP430

Recommended Posts

if u read the "device output signal" column, it says TA0.0 for P1.1-3, P1.5-7

 

this means for clock output on timer 0, channel 0, u can use P1.1 or P1.5, the 3 and 7 are pin number of the device. u just need to use P1SEL register to select either BIT1 or BIT5 and use that pin to drive your led / servo, etc.

 

similarly we have TA0.1, TA0.2, TA1.0, TA1.1, TA1.2 mapping entries for 2 x 3 channels timer output (2 timer TA0 and TA1, and 3 channels each)

 

also note there are less choice on which pin to use on 20 pin devices as there are no port 3 available.

 

WOW thanks, you are amazing man that is exactly what i needed...cheers

Share this post


Link to post
Share on other sites

if u read the "device output signal" column, it says TA0.0 for P1.1-3, P1.5-7

 

this means for clock output on timer 0, channel 0, u can use P1.1 or P1.5, the 3 and 7 are pin number of the device. u just need to use P1SEL register to select either BIT1 or BIT5 and use that pin to drive your led / servo, etc.

 

similarly we have TA0.1, TA0.2, TA1.0, TA1.1, TA1.2 mapping entries for 2 x 3 channels timer output (2 timer TA0 and TA1, and 3 channels each)

 

also note there are less choice on which pin to use on 20 pin devices as there are no port 3 available.

You know, that's really a bit confusing. I though P1.1-3 would mean P1.1 through P1.3. Same with P1.5-7.

Share this post


Link to post
Share on other sites

You know, that's really a bit confusing. I though P1.1-3 would mean P1.1 through P1.3. Same with P1.5-7.

yes, i do found them confusing. it took me quite a while to figure it out. in my opinion it's better if they leave the pin number out.

Share this post


Link to post
Share on other sites

if u read the "device output signal" column, it says TA0.0 for P1.1-3, P1.5-7

 

this means for clock output on timer 0, channel 0, u can use P1.1 or P1.5, the 3 and 7 are pin number of the device. u just need to use P1SEL register to select either BIT1 or BIT5 and use that pin to drive your led / servo, etc.

 

similarly we have TA0.1, TA0.2, TA1.0, TA1.1, TA1.2 mapping entries for 2 x 3 channels timer output (2 timer TA0 and TA1, and 3 channels each)

 

also note there are less choice on which pin to use on 20 pin devices as there are no port 3 available.

 

I was checking the post about "Post your LED Fader Code":

http://forum.43oh.com/topic/3023-post-your-led-fader-code/

 

His code works fine on LP and it is working on P1 BIT6. The document  slas735h was revised on  February 2013.

So now I scratch my head thinking if supposed to be BIT1 or BIT5, how in hell is working on BIT6!!??

Share this post


Link to post
Share on other sites

I was checking the post about "Post your LED Fader Code":

http://forum.43oh.com/topic/3023-post-your-led-fader-code/

 

His code works fine on LP and it is working on P1 BIT6. The document  slas735h was revised on  February 2013.

So now I scratch my head thinking if supposed to be BIT1 or BIT5, how in hell is working on BIT6!!??

he's using CCR1 (channel 1) so we need to find a pin for TA0.1 which can be P1.2 or P1.6. P1.6 he used.

 

i would make the same choice as P1.6 is the green LED. sometimes we "pick" the timer + channel solely because the we have layout constraints. in this case we want to use the LP on board green LED for demo.

 

i would choose the timer + channel so that i can have pin matching the breadboard layout for my liking.

 

note also from table 12 that 20pin device is not possible to use TA0.2 as there are on P3. so there are some advantages to do smd.

 

/EDIT u may also be confused w/ the timer 0 and 1 register macros. the ones prefixed w/ TA1... are for timer 1. those w/o prefix are for TA0 (ex. CCR0 = TA0CCR0, CCTL0 = TA0CCTL0). if i were to use both timers in an application, i would prefix also timer 0 to make it more coherent and more readable. tried it on your compiler

Share this post


Link to post
Share on other sites

If I wanted to learn "energia codebase or easyMSP", I rather go for AVR and arduino....

You can learn something from looking at the underlying code even if you never intend to compile it.  You want example code -- there it is.

Share this post


Link to post
Share on other sites

You can learn something from looking at the underlying code even if you never intend to compile it.  You want example code -- there it is.

I don't know what is your problem jpnorair, you have used the 3 last posts using many words to push me away, explain the obvious and not adding anything of real value....that I'm sure you have plenty to say.

It takes you the same amount of words to be helpful!

Share this post


Link to post
Share on other sites

he's using CCR1 (channel 1) so we need to find a pin for TA0.1 which can be P1.2 or P1.6. P1.6 he used.

 

i would make the same choice as P1.6 is the green LED. sometimes we "pick" the timer + channel solely because the we have layout constraints. in this case we want to use the LP on board green LED for demo.

 

i would choose the timer + channel so that i can have pin matching the breadboard layout for my liking.

 

note also from table 12 that 20pin device is not possible to use TA0.2 as there are on P3. so there are some advantages to do smd.

 

/EDIT u may also be confused w/ the timer 0 and 1 register macros. the ones prefixed w/ TA1... are for timer 1. those w/o prefix are for TA0 (ex. CCR0 = TA0CCR0, CCTL0 = TA0CCTL0). if i were to use both timers in an application, i would prefix also timer 0 to make it more coherent and more readable. tried it on your compiler

Once again, thanks for exaplining and for your time SimpleAVR

 

Now I understand that table on the datasheet. You are right, I'm getting a bit confused. I can see CCR0 and CCR1 mentioned, on the line:

TA1CCR0 = 50000; 

 

As I read it as TA1 on CCR0(making no sense), but certainly is not the case. How did you find CCR1?

Share this post


Link to post
Share on other sites

Now I understand that table on the datasheet. You are right, I'm getting a bit confused. I can see CCR0 and CCR1 mentioned, on the line:

TA1CCR0 = 50000; 

 

As I read it as TA1 on CCR0(making no sense), but certainly is not the case. How did you find CCR1?

 

the breather code u were reading uses timer 0 for pwm output to the green led. to achieve the breathing effect, he used another timer (timer 1) to change the brightness of the led via adjust the timer 0 pwm setup duty cycle. for timer 1, there is no output pin, but instead a s/w interrupt in which the interrupt handler make things happen (set CCR1 / TA0CCR1).

 

 

 

for the CCR1 = TACCR1 = TA0CCR1 relationship, i noticed them after reading too many codes. from the earlier TI examples for the F2xxx series, they had CCRx and TACCRx.

 

although not explicitly mentioned, CCR means capture and compare register. TA means timer A, TA0 means timer A 0.

 

i guess when u are working w/ the "lesser" devices like F2012/G2231 etc, where u only have one timer, writing CCRx, CCTLx (or TACCRx, etc) make sense as there is only one timer. so when i read codes and see CCRx i will mentally add TA0 prefix.

 

it could be confusing when u 1st approaches these. i don't want to tell u how i got bitten by OUTMOD_4 = OUTMOD2.

 

but they are there for good purpose when used in different contexts / coding styles. i am sure many of us are using different macros for the same registers, like many of us are trying to help w/ questions in the forum in different ways. some way are better than others in certain context and they are all for good intentions to solve your questions.

Share this post


Link to post
Share on other sites

I don't know what is your problem jpnorair.

I'm guessing it's just a generation gap.  I intend no hostility.  In the two days this thread has been up, you've got your answer, so that's good.  Another way to get to the same place would have been to figure it out yourself, given pointers to examples.  Different styles, I guess.

Share this post


Link to post
Share on other sites

I'm guessing it's just a generation gap.  I intend no hostility.  In the two days this thread has been up, you've got your answer, so that's good.  Another way to get to the same place would have been to figure it out yourself, given pointers to examples.  Different styles, I guess.

I don't know about the generation gap, I'm clear that you intend no hostility. I think that perhaps your have  a more trained eye, and some things looks obvious after a while.

I think that the best way to explain is to place yourself into someone else's shoes, that's why I tried to explain you my frustration and confusion along with my query.

But, anyways no hard feelings from my side...and I want to share some code (to all the noobs like me), that I think can be really helpful. The code is not all mine, I have edited ideas from different books. 

 

 

 

------------------------------

 

#include "msp430g2553.h"
 
 
void main(void) {
    WDTCTL = WDTPW + WDTHOLD; // disable WDT
    
    
P1SEL |= BIT6;
P1DIR |= BIT6; 
TACTL |= TASSEL1; //Use ACLK
CCR0 = 32767; //Max value
CCR1 = 8500;   //modify this value to get the right duty cycle
CCTL1 = OUTMOD_3; //Output Mode 3 is Set on CCR1, clear
//on CCR0
//Turn On Timer
TACTL |= MC_1;
 
for(;;){
   _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
 
}
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void) {
P1OUT |= BIT6;
}
----------------------------------------------
The code is fully working under msp430-gcc
 
Just confused a bit with the fact that the are different channels:
How many in total I heard about 15 or so, is that correct
does it mean that you could use one stepper per channel
how do I access this channels
.Btw, I read the manual before I'm asking this hehhe

Share this post


Link to post
Share on other sites
CCR0 = 32767; //Max value

since it's unsigned, u can safely go to 0xffff or 65536.

 

g2553 has 2 timer a, each have 3 channels. other devices might have more but i only play w/ the dip devices (i.e. low-end toy devices).

 

there are quite a bit of pwm related projects in the projects area. the most extreme i done is to do a 5 channel polyphonic tune player w/ a 20 pin g2553. i do recall RobG show us how to drive "many" servos.

 

 

se 5 channels (20

Share this post


Link to post
Share on other sites
CCR0 = 32767; //Max value

since it's unsigned, u can safely go to 0xffff or 65536.

 

g2553 has 2 timer a, each have 3 channels. other devices might have more but i only play w/ the dip devices (i.e. low-end toy devices).

 

there are quite a bit of pwm related projects in the projects area. the most extreme i done is to do a 5 channel polyphonic tune player w/ a 20 pin g2553. i do recall RobG show us how to drive "many" servos.

 

 

se 5 channels (20

 

 

I was looking at the header file, but I can't find it mentioned  as Unsigned....how do you know this, is it in any manual?, I just followed 32767 becasue I thought that I had to match the clock speed. The limitations on choosing a diiferent CCR0 values: does it come from the var type only, or do you have hardware constrains?

Do you think that some outmnodes are better than others for a particular application (or suitable),: dc motors, steppers, servos, led etc?

 

Please send a link to you video of polymorphic tune player :smile:

Meanwhile I'm going to test the SLAA120 "PWM DC Motor Control Using Timer_A of the MSP430" it seem like a good next step on my learning curve.

 

Thanks and greets all

Share this post


Link to post
Share on other sites

@@cromiumlake - have you tried out Grace from TI (built into CCS or as a stand-alone app)?  It can be a bit of a crutch - but I find it a great way to get a good look at how the registers work.  It has some bugs when the GPIO settings unfortunately (just in vs out) but works great for timer and clock configuration.

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.


×
×
  • Create New...