Jump to content
43oh

PWM: Which Output Pin?


Recommended Posts

Just started playing with my Launchpad (MSP430G2231) and I'm working my way through the PWM (ta_20.c) code sample:

 

P1DIR |= 0x0C;                            // P1.2 and P1.3 output
P1SEL |= 0x0C;                            // P1.2 and P1.3 TA1/2 otions
CCR0 = 128;                                // PWM Period/2
CCTL1 = OUTMOD_6;                   // CCR1 toggle/set
CCR1 = 32;                                 // CCR1 PWM duty cycle
TACTL = TASSEL_1 + MC_3;          // ACLK, up-down mode

 

It works fine and I understand most of it except for one thing: What determines that the PWM output goes to P1.2?

 

I see the port direction and function select but I can't figure out where Timer_A is configured to use that particular port.

 

And following on from that, how can I change the PWM output to a different pin, P1.1 for instance?

 

Many thanks.

 

- Adam

Link to post
Share on other sites

P1.2 is Timer_A2.TA1

 

You might be interested in trying the Grace plugin for CCS to learn more about the GPIO. I used it to get the basics down of which pins do what.

http://focus.ti.com/docs/toolsw/folders/print/grace.html?DCMP=Grace&HQS=Other+EM+grace

or just use the datasheet

http://focus.ti.com/lit/ds/symlink/msp430g2231.pdf page4 has the pinouts

Link to post
Share on other sites

Module's outputs/inputs are hardwired to specific pin(s) and you cannot change it, you can only enable/disable them. As gwdeveloper already wrote, see device specific datasheet, there's a terminal function table there. Also, enabling pin function is not always done the same way, sometimes you have to configure module's registers, sometimes you simply set the PxSEL1 register.

Link to post
Share on other sites

Best advice is to download the datasheet for a list of what ports have access to what functions.

 

While all port pins support general input/output.

 

The timer example used to create a PWM output, uses the internal timer's.

Example: Timer_A0 out is only available on specific pins (P1.1 and P1.5), the same with Timer_A1 is (P1.2 and P1.6), which give you two options.

 

When starting a project best to look at what I/O functions you will be using first, and then write the code.

 

If you used software to generate the PWM, then you could use any of the port pins.

 

Many of the TI demo's show off using the device in low power mode, but no reason you have to use them that way.

Link to post
Share on other sites

Thanks everyone - your help is much appreciated.

 

Although I had been reading the Family User's Guide and the device datasheet, I hadn't made the connection that the function was hardwired - my background is in programming so the electronics aspect of this is still new to me.

 

I have just downloaded the Grace plug-in and it's excellent, just what I needed to help bridge my knowledge gap between the software and hardware. TI's documentation is superb but there's so much of it that it's difficult not to be totally overwhelmed, Grace should help with that considerably.

 

- Adam

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