Jump to content
Sign in to follow this  
Jonoveve

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.

Share this post


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() 

Share this post


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.

Share this post


Link to post
Share on other sites

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 !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×