- UID
- 143562
- 性别
- 男
|
请教:本人用9S08DZ60 做了个PWM输出可是I/O口电平一直没有跳变,有哪位大虾帮忙看一下,谢谢!
#include
#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(;;)
{
}
}
|
|