/*---------------------------------------------------------------------------------------------------------*/
/* */
/* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved. */
/* */
/*---------------------------------------------------------------------------------------------------------*/
//***********************************************************************************************************
// Website: http://www.nuvoton.com
// E-Mail : MicroC-8bit@nuvoton.com
//***********************************************************************************************************
#include "ML51.h"
/**
* [url=home.php?mod=space&uid=247401]@brief[/url] Timer2 capture mode demo.
* @param None
* [url=home.php?mod=space&uid=266161]@return[/url] None
* [url=home.php?mod=space&uid=1543424]@Details[/url] None
*/
void Capture_ISR (void) interrupt 12
{
clr_CAPCON0_CAPF0; // clear capture0 interrupt flag
clr_T2CON_TF2;
printf("\n TM2 CAP 0x%bX",C0L);
}
void main (void)
{
MFP_P31_UART0_TXD;
P31_QUASI_MODE;
UART_Open(24000000,UART0_Timer1,115200);
ENABLE_UART0_PRINTF;
/* Set P3.0 as input capture pin*/
MFP_P30_IC0;
P30_INPUT_MODE;
GPIO_Pull_Enable(Port3,SET_BIT2,PullUp);
/* Include capture.c */
TIMER2_Capture(IC0,CaptureEither,0);
TIMER2_Capture_Interrupt(Enable);
ENABLE_GLOBAL_INTERRUPT;
while (1);
}
|