Jump to content
43oh

Recommended Posts

Hi,

 

I'm new to the forum and have a question about the PWM clock. I'm using the TM4C123GH6PM version of the Tivia C. I'm a little confused about how to determine the period of the clock.

 

I found an example that went something like this:

 

SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); 

SysCtlPWMClockSet(SYSCTL_PWMDIV_16);

 

Which looks like it should set the PWM clock to run at 1 MHz. If I call SysCtlPWMClockGet(), I get 16,000,000, which seems right, but if I call SysCtlPWMClockGet() I get 1,441,792. 

 

My question is whether I'm getting 1 MHz on the PWM clock and the numbers are different, or is there something I'm missing.

 

Thanks in advance.

Link to post
Share on other sites

Hi L,

 

Thanks for responding. Sorry, I didn't catch that on my re-read. Let me restate that paragraph:

 

Which looks like it should set the PWM clock to run at 1 MHz. If I call SysCtlClockGet(), I get 16,000,000, which seems right, but if I call SysCtlPWMClockGet() I get 1,441,792. I guess I would have expected 1,000,000.

 

I'm using TivaWare_C_Series-2.0.1.11577. Is there a later or better version to use?

 

Thanks in advance.

Link to post
Share on other sites

Thanks for your response, but I'm not sure I understand what you're saying. I think you're saying that it's just a number and not a number of cycles per second. Is the PWM clock really running at 1MHz, or 1,441,792 Hz? When the system clock is running at 16MHz, SysCtlClockGet returns 16,000,000. If it is really running at 1 MHz it seems that they are inconsistent. Maybe I shouldn't be surprised ;-)

Link to post
Share on other sites

Hi,

Nothing new under the sun, just weird things: the below comments are from peripheral driverlib/sysctl.c file:

 

SysCtlPWMClockGet:

 

//! This function returns the current PWM clock configuration.
//!
//! \return Returns the current PWM clock configuration; is one of
//! \b SYSCTL_PWMDIV_1, \b SYSCTL_PWMDIV_2, \b SYSCTL_PWMDIV_4,
//! \b SYSCTL_PWMDIV_8, \b SYSCTL_PWMDIV_16, \b SYSCTL_PWMDIV_32, or
//! \b SYSCTL_PWMDIV_64.
 
So no frequency, just configuration. Just check for your case - help yourself with the user manual
Regards,
L
Link to post
Share on other sites

If it is really running at 1 MHz it seems that they are inconsistent. Maybe I shouldn't be surprised ;-)

Yes, I think you shouldn't be surprised.

 

This is part of why I prefer to use the CMSIS register interface: I don't have to guess what intermediate helper functions (are supposed to) do. Instead I have to understand the hardware's underlying capabilities and interface, which is initially more effort but in the long run more rewarding. By not supporting CMSIS TI makes this unnecessarily difficult, and I'm probably going to continue to complain about it for as long as I'm using the otherwise nice devices.

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