Daniel Phillips

MC 9S12C128  PWM TESTING problems

Discussion created by Daniel Phillips on Sep 6, 2008
Latest reply on Sep 12, 2008 by Daniel Phillips
I recently purchased a NANOCORE12MAX128 which has a MC9S12C128 microcontroller form freescale on board. This is what is advertised and i can actually read this off top of the chip


When I load up codwewarrior and attempt to run the True-Time Simulator and Real Time Debugger, it says
Set derivative
The MCUID of this derivative is 0x2CF
Part ID returned from the connected derivative matches with multiple derivatives

and the only options it has are for MC9S12Q 64, 96, and 128. This is important as the Q variant only has 4 PWM channels unlike the C model which has 6. So I think that I have a C model, but the software / serial monitor is misidentifying the target. At first I just selected the Q128, and that worked well for a while, but when I tried to run this code to see if my pwm works. 

#include <hidef.h> /* common defines and macros */
#include <mc9s12c128.h> /* derivative information */

#pragma LINK_INFO DERIVATIVE "mc9s12c128"

void main(void)
//Enabling portT for PWM0
MODRR =0x05;
The line MODRR=0x01 IS (IN MY ONE)
necessary if your PWM
in not multiplexed with the Timer module.
Check the block diagram of your circuit.

PWMSCLA=0xFA; //HEX 250 C8

PWMPER0=0xFA; //HEX 250
PWMDTY0=0x7D; //HEX 125

PWMPER2=0xFA; //HEX 250



//f=4MHz/250/128 (prescale A)/250 (scale a) = 0.5 Hz

running this code causes the PWM channel 0 to beat at 0.5 Hz, (first led on school board) with a 50% duty cycle. But PWM channel 2 beats way faster, as if it is not being scaled down (a red led with 340 ohm resistance in series). What is causing this problem!!@@?? I have been able to vary the duty cycle on both the correctly 0.5Hz pins and the ones that flash tooo fast.
I have tested the first 5 channels of the PWM on port T using bit masks on the MODRR PWMCLK and PWME registers. and 0 and 1 work, 2 and 3 have the higher frequency malfunction and 4 works at 0.5 Hz.