Jump to content
43oh

Change resolution PWM with msp430FR6989


Recommended Posts

Hello.

 

I am trying to change the output PWM resolution in my board for feed a VCO .

With enegia i can use 8 bits resolution but in the datasheet i can see that the output PWM resolution is 16 bits.

 

I have read this Topic http://forum.43oh.com/topic/5765-analogwrite-precision-question/ they use PWMWrite(Pin,Steps,duty cycle,Frequency) but, with msp430 it does not work.

 

There are any solution to increase the resolution of PWM output for msp430 like in Tiva C?

 

 

Best Regards.

P.C.

Link to post
Share on other sites

You can use analogResolution() to set the PWM resolution. Note that this is tied with the analogFrequency() by default it is set to ~490 Hz (F_CPU/490).

This means that for the MSP430FR6989 running at 16 Mhz the max you can count up to is 16 MHz/490 = 32653 which is your max resolution.

 

e.g.

#define PWM_PIN 11
#define PWM_FREQ 490 // the default
#define PWM_RES (F_CPU / PWM_FREQ)


void setup() {
  /* set the PWM frequency */
  analogFrequency(PWM_FREQ);
  /* set the PWM resolution */
  analogResolution(PWM_RES);
  /* 490 Hz / 50% duty cycle on pin 11 */
  analogWrite(11, PWM_RES/2); 
}

void loop() 
Link to post
Share on other sites

 

You can use analogResolution() to set the PWM resolution. Note that this is tied with the analogFrequency() by default it is set to ~490 Hz (F_CPU/490).

This means that for the MSP430FR6989 running at 16 Mhz the max you can count up to is 16 MHz/490 = 32653 which is your max resolution.

 

e.g.

#define PWM_PIN 11
#define PWM_FREQ 490 // the default
#define PWM_RES (F_CPU / PWM_FREQ)


void setup() {
  /* set the PWM frequency */
  analogFrequency(PWM_FREQ);
  /* set the PWM resolution */
  analogResolution(PWM_RES);
  /* 490 Hz / 50% duty cycle on pin 11 */
  analogWrite(11, PWM_RES/2); 
}

void loop() 

Thanks you very much. it was what i want.

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

For the analogFrequency function, what are the limitations? How high in frequency can it go?. Im assuming it would be dependent on clock frequency, correct?

Im looking in particular to generate a 450kHz square wave (actually fixed 50% duty cycle). Would that be possible on an MSP430 running at 10 or 16Mhz clock? 
Thanks !

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