Page 1 of 1

PWM Test Program for 5213 (per request from GreenE)

Posted: Fri Mar 25, 2011 1:50 pm
by joepasquariello
GreenE,

Here is a PWM test program I wrote for the MOD5213 a couple of years ago. It configures PWM output on PWM0 and counts pulses on DTIN3. The function for setting up PWM0 is general enough to allow setting clock frequency, PWM periods, and duty cycles, but it's up to you to choose values that "make sense". The example shown should give you a good start.

When setting register bits, I use the macros in FreeScale's standard header files for the 5213. You can download them from FreeScale by searching for "MCF5213 header files". I just put all of headers into the MOD5213\Include folder, and since that's in the standard include search path, you don't have to change any settings in your NBE project.

Let us know how it goes.

Joe

Re: PWM Test Program for 5213 (per request from GreenE)

Posted: Fri Mar 25, 2011 3:06 pm
by Ridgeglider
GreenE and Joe:
Here are the zipped freescale headers for a variety of the NB platforms... Just add the 5213 folder's contents to the existing nburn/mod5213/include folder as shown in the picture below.
5213Includes.png
5213Includes.png (37.1 KiB) Viewed 6605 times
I like using them because the bit fields of most of the registers are named which makes the coding intent quite a bit clearer.

The headers came from: http://www.microapl.co.uk/CFInit/cfinit_download.html which installs a nice configuration tool for the coldfire processors. A great way to set up and familiarize yourself with some of the CF peripherals...

Once CFinit is installed, go to C:\Program Files\ColdFire Init\headers\Freescale to see all of the header files. Here's adescription: http://www.microapl.co.uk/CFInit/cfinit_main.html

Note that unfortunately CFInit is a little dated and only runs on a 32 bit windows platform.