Jonoveve 4 Posted February 5, 2016 Share Posted February 5, 2016 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. Quote Link to post Share on other sites
energia 485 Posted February 5, 2016 Share Posted February 5, 2016 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() Quote Link to post Share on other sites
Jonoveve 4 Posted February 12, 2016 Author Share Posted February 12, 2016 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. energia 1 Quote Link to post Share on other sites
IEC44 0 Posted October 1, 2018 Share Posted October 1, 2018 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 ! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.