Jump to content
43oh

analogFrequency not working CC3200 LP


Recommended Posts

Hi all,

 

I am trying to use the PWM at different frequency wrt to the default one (490Hz right?).

 

i tried to use the function analogFrequency(20000) but I got a problem when compliling: 

 

(.text.setup+0xb6): undefined reference to `analogFrequency'
collect2.exe: error: ld returned 1 exit status
 
Is this function implemented for the CC3200? If not, how can I change the PWM frequency?
 
Thanks!
Link to post
Share on other sites

@@datapassion - I don't know what your application is or how you are using it (also I don't normally use PWM with the CC3200)....  I played with this sketch a bit just to see what it did:

#include <wiring_analog.c>
#include <wiring_private.h>

int PWMpin = 29;                 // red LED
int numberOfSteps = 100;
int dutyCycle = 50;
int frequency = 60;

void setup()
{
  // put your setup code here, to run once:
  pinMode(PWMpin, OUTPUT);
  PWMWrite(PWMpin,numberOfSteps,dutyCycle,frequency);
}

void loop()
{
  // put your main code here, to run repeatedly:

}

It seems to dim and brighten the red LED on the LaunchPad more or less as expected at least down to 30 Hz or so.  Much higher values seem to behave but I don't have an oscilloscope.  At some point it is going to have limitations.

 

The code for PWMWrite() is in wiring_analog.c as is analogWrite().  analogWrite() calls PWMWrite so Energia is using the function.  That is about the depth of my knowledge.  Have you tried playing with it to see if it does what you want?

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

OK - now that I have an oscilloscope :D I played with this a bit more to see what it did.  I essentially used the code in my post above.  Here is what I found....

 

It doesn't seem to work below about 20 Hz - for some reason it gives really spurious (high) results down there.  For example at 10Hz I measured 21.6 Hz on the oscilloscope.

Above 20 Hz it is pretty much spot on until it gets to 100 KHz or so where it starts to deviate a little.  Here are some examples....

 

CC3200     Oscilloscope

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

51,200        51.20 KHz

102400       102.3 KHz

5000000     497.0 KHz

1000000     988.1 KHz

2000000     1.95 MHz

 

And here are a couple of screenshots:

 

Looking good  at 1 KHz

 

post-45284-0-61613200-1437805333_thumb.jpg

 

Not too bad at 500 KHz

 

post-45284-0-25437200-1437805358_thumb.jpg

 

Pretty sloppy at 4 MHz

 

post-45284-0-69674300-1437805569_thumb.jpg

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