voidmcf5213_incap0_init(void){ /* GPT Channel 0 configured for Input Capture Capture on rising edge GPT Channel 1 configured as GPIO input GPT Channel 2 configured as GPIO input GPT Channel 3 configured as GPIO input GPT Timer clock = 40.00 MHz The following GPT interrupt sources are enabled: Channel 0 Fast clearing of interrupts disabled */ MCF_GPTA_GPTIOS = 0; MCF_GPTA_GPTOC3M = 0; MCF_GPTA_GPTSCR1 = MCF_GPTA_GPTSCR1_GPTEN; MCF_GPTA_GPTTOV = 0; MCF_GPTA_GPTCTL1 = MCF_GPTA_GPTCTL1_OUTPUT3_NOTHING | MCF_GPTA_GPTCTL1_OUTPUT2_NOTHING | MCF_GPTA_GPTCTL1_OUTPUT1_NOTHING | MCF_GPTA_GPTCTL1_OUTPUT0_NOTHING; MCF_GPTA_GPTCTL2 = MCF_GPTA_GPTCTL2_INPUT3_DISABLED | MCF_GPTA_GPTCTL2_INPUT2_DISABLED | MCF_GPTA_GPTCTL2_INPUT1_DISABLED | MCF_GPTA_GPTCTL2_INPUT0_RISING; MCF_GPTA_GPTSCR2 = MCF_GPTA_GPTSCR2_PR_4; MCF_GPTA_GPTPACTL = 0; MCF_GPTA_GPTDDR = 0; MCF_GPTA_GPTC0 = 0; MCF_GPTA_GPTC1 = 0; MCF_GPTA_GPTC2 = 0; MCF_GPTA_GPTC3 = 0; MCF_GPTA_GPTFLG1 = 0x0f; MCF_GPTA_GPTIE = MCF_GPTA_GPTIE_CI0;}
.extern _IRQ_INCAP0 vector108: .long _IRQ_INCAP0
// set the interrupt level IL and the interrupt priority IP MCF_INTC_ICR55 = MCF_INTC_ICR_IL(7) | MCF_INTC_ICR_IP(6); //PIT MCF_INTC_ICR44 = MCF_INTC_ICR_IL(7) | MCF_INTC_ICR_IP(7); //input capture // Unmask 55 = PIT0 interrupt source MCF_INTC_IMRL &= ~(MCF_INTC_IMRL_MASKALL); MCF_INTC_IMRH &= ~(MCF_INTC_IMRH_INT_MASK55); //PIT MCF_INTC_IMRH &= ~(MCF_INTC_IMRH_INT_MASK44); //input capture asm( move.w #0x2000, sr ); // enable all priority levels
__declspec(interrupt)void IRQ_INCAP0( void ){ incap_val = MCF_GPTA_GPTC0; MCF_GPTA_GPTFLG1 |= MCF_GPTA_GPTFLG1_CF0; MCF_GPIO_PORTTC &= ~2; }