Chih Hung Lo

Does anyone have experience in MC9S08AW32

Discussion created by Chih Hung Lo on Mar 16, 2007
Latest reply on Mar 16, 2007 by Frank Volker
Hi all:

I'm a newbie in HCS08.

Now, I have a problem about the TPM in MC9S08AW32.

I use the 4MHz crystal and set the bus clock to 20MHz.
And I want to set a interrupt per 500usec.
So I use the TPM module, but it isn't work to me.
I don't know what's happen?

Does anyone can help me,thanks.

My workaround:
Codewarrior V3.1 for HC(S)08

Below is my code.

#include // For enable interrupts macro
#include // Include peripheral declarations
#define LED1 PTCD_PTCD2

interrupt Vtpm1ovf void TPM1OVFISR(void)
if(TPM1SC_TOF) // 500us

void IniCpu(void)
PTADD=0b00000000; // I/O data direction, 1:smileysurprised:utput, 0:Input
PTBDD=0b00000000; // I/O data direction, 1:smileysurprised:utput, 0:Input
PTCDD=0b01011100; // I/O data direction, 1:smileysurprised:utput, 0:Input
// Set the PTC5 is a SCI Rx2,PTC3 is SCI Tx2
PTEDD=0b00000001; // Set the PTE1 is a SCI Rx1,PTE0 is SCI Tx1
PTFDD=0b11110000; // Set PTF[6:7] are output, PTF[4:5] are PWM output

// --- Timer1 configuration ---
TPM1SC_PS = 0; // Select prescale = 1
TPM1MOD = 10000;
TPM1SC_CLKSA=1; // Select bus clock

void main(void)
SOPT=0x00; // Disable cop module
IniPLL(); // Initial PLL module
IniCpu(); // Initial Cpu

EnableInterrupts; // Enable interrupts