本帖最后由 FSL_TICS_A 于 2014-10-8 09:44 编辑
#include "MKL05Z4.h"
int main(void)
{
int tempCount,tempCount2 = 0;
// clocking //
for(tempCount = 0;tempCount<=200;tempCount++);
for(tempCount = 0;tempCount<=200;tempCount++);
for(tempCount = 0;tempCount<=200;tempCount++);
// 外设时钟
SIM_SOPT2 |= 0x01000000; // clock sel for the timer0 // MCGFLLCLK
SIM_SCGC5 |= 0x00000400; // gating of clock // Port B Clock Gate Control
SIM_SCGC6 |= 0x01000000; // gating of timer //TOM0 Clock gate control
TPM0_SC |= 0x00000004; // every
// port settings //
PORTB_PCR8 |= 0x00000100; // alternative pin mux selection // -- this 2 for PWM
GPIOB_PDDR |= 0x00000100; // pin direction // output
//PORTB_PCR9 |= 0x00000200;
// GPIOB_PDDR |= 0x00000200;
//timer0//
TPM0_CNT = 0; // counter value. NOTE :- when debug is aactive this is not incremented !!!!!!!!! //
TPM0_CNT = 0; // counter value. NOTE :- when debug is aactive this is not incremented !!!!!!!!! //
TPM0_CONF |= 192; // counter runs in debug mode as well //
TPM0_MOD = 0xFFFF; // period count // 1309
TPM0_SC |= 0x00000008;
while(1){
if((TPM0_SC & 0x00000080) == 0x00000080){
GPIOB_PTOR |= (1<<8);
//Delay(20000);
//tempCount++;
TPM0_SC |= TPM_SC_TOF_MASK; //write 1 to clear
}
else
{
tempCount2++;
}
}
}
|