PWM Test Program for 5213 (per request from GreenE)

Post your example source code and application notes to share with others
Post Reply
Posts: 78
Joined: Mon Apr 28, 2008 7:32 am

PWM Test Program for 5213 (per request from GreenE)

Post by joepasquariello » Fri Mar 25, 2011 1:50 pm


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.

PWM test program for 5213
(3.76 KiB) Downloaded 360 times

Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

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

Post by Ridgeglider » Fri Mar 25, 2011 3:06 pm

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 (37.1 KiB) Viewed 4694 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: 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:

Note that unfortunately CFInit is a little dated and only runs on a 32 bit windows platform.
(107.78 KiB) Downloaded 302 times

Post Reply