Ryan Starret

PWM Setup Issue - Can't make TPMCH0 work!

Discussion created by Ryan Starret on Dec 23, 2006
Latest reply on Jan 30, 2008 by Thomas Walsh
Hi everyone... Here is the deal. I wrote some simple code:

void main(void) {

EnableInterrupts; /* enable interrupts */

TPMMODH = 0x27; // set period to x10,000
TPMMODL = 0x09;
TPMC1VH = 0x13; // set duty cycle to x5,000
TPMC1VL = 0x88;
TPMC1SC = 0x24; // set channel 1 for PWM
TPMC0VH = 0x13; // set duty cycle to x5,000
TPMC0VL = 0x88;
TPMC0SC = 0x24; // set channel 1 for PWM
TPMSC = 0x08; // select bus clock and start timer

for(;:smileywink: {
__RESET_WATCHDOG(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave main */

Well... Actually I partially wrote it. Most if it came out of a sample application that came with the MC9S08QG8 demo board. When I load this onto the chip I can measure the output at TPMCH1 as 1.67V which is rough what I would expect at 50% duty cycle. For the life of me I can't get any output whatsoever on TPMCH0... even though I just copied and pasted the code from 3 lines above it and changed a couple numbers.

After fighting with this for the day I've decided to post here. If anyone has any ideas I would be greatly appreciative! I'm sure I'm just missing something obvious and crucial.