See the below, This program code of PWM can run EVB9S08DZ60 but we don't generat PWM .
Could you help me check it ? Could you send me a source code of PWM about EVB9S08DZ60 ?
Thank you very much for you help!
#include <hidef.h>
#include "derivative.h" /* include peripheral declarations */
#define PUSH_PTA4 0
#define PUSH_PTA5 1
#define PUSH_PTA6 2
#define PUSH_PTA7 3
char push;
/////////////////////////////////////////////////////////////////////////////////////////
// PeriphInit
// --------------------------------------------------------------------------------------
// Initializes various registers and peripherals
/////////////////////////////////////////////////////////////////////////////////////////
void PeriphInit(void)
{
// Clear COP Watchdog timeout
SOPT1 = 0x00;
// Select FBE MCG mode (IREFS=0, CLKS=10)
MCGC1 = 0xB8;
// LP=0 and selects external high frequency crystal clock
MCGC2 = 0x36;
// PLLS=0
MCGC3 = 0x00;
// Wait until the initialization cycle of the external crystal clock is completed
while(!(MCGSC&0x02))
;
//Select fBUS/2 as ADC clock source, clock divide 2 and 8 bit conversion mode
ADCFG = 0x21;
// Configure PTD port as output and power off LEDs
PTDD = 0xFF;
PTDDD = 0xFF;
// Enable AD1 and AD2 pins
APCTL1 = 0x06;
// Enable PTB input pull-downs
PTBDD = 0x00;
PTBPS = 0xFF;
PTBES = 0xFF;
PTBPE = 0xFF;
//tpm1 configure
TPM1MODH = 0x00;
TPM1MODL = 0x50;
TPM1SC = 0x0f;
TPM1C0VH = 0x00;
TPM1C0VL = 0x14;
TPM1C0SC = 0x14;
//TPM1C0VH = 0x00;
//TPM1C0VL = 0x14;
//TPM1C0SC = 0x5a;
// Enable PTA4, PTA5, PTA6 and PTA7 input pull-ups
PTAPE = 0xF0;
}
/////////////////////////////////////////////////////////////////////////////////////////
// MAIN
/////////////////////////////////////////////////////////////////////////////////////////
void main (void)
{
PeriphInit();
EnableInterrupts;
push = PUSH_PTA4;
for(;
{
}
}
- Mod Corrected Subject line -
Message Edited by Alban on 2007-01-25 01:49 PM
Guosheng,
The following line from your code:
TPM1C0SC = 0x14;
will configure the channel for Output Compare.
To configure for Edge-aligned PWM, the following should work:
TPM1C0SC = 0x28; //=============== for high-true pulses
or
TPM1C0SC = 0x24; //=============== for low-true pulses
I noticed your topic line mentions "9S08GZ60" and your message discusses "9S08DZ60", which I assume is correct, since you stated that you were using the EVB9S08DZ60 board. Please be certain to consult the correct document -- MC9S08DZ60.PDF for the 9S08DZ60. The timer setup differs between these 2 devices.
Frank
- Mod Corrected Subject line according to thisobj obsvervation-
Message Edited by Alban on 2007-01-25 01:49 PM