/*---------------------------------------------------------------------------------------------------------*/
/* */
/* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved. */
/* */
/*---------------------------------------------------------------------------------------------------------*/
//***********************************************************************************************************
// Website: http://www.nuvoton.com
// E-Mail : MicroC-8bit@nuvoton.com
//***********************************************************************************************************
//***********************************************************************************************************
// File Function: ML51 pin interrupt demo code
//***********************************************************************************************************
#include "ML51.h"
/**
* [url=home.php?mod=space&uid=247401]@brief[/url] Port0~5 Interrupt Subroutine
* @param None
* [url=home.php?mod=space&uid=266161]@return[/url] None
* [url=home.php?mod=space&uid=1543424]@Details[/url] PIF 0~7 declair in GPIO_EnableInt interrupt.
*/
void PinInterrupt_ISR (void) interrupt 7
{
if ((PIF&SET_BIT0)==SET_BIT0)
{
PIF&=CLR_BIT0;
P30 = ~P30;
printf ("\n PIT0 INT");
}
else if ((PIF&SET_BIT3)==SET_BIT3)
{
PIF&=CLR_BIT3;
P30 = ~P30;
printf ("\n PIT3 INT");
}
}
void main (void)
{
/* Setting Multi function pin setting for GPIO toggle
* include gipo.c in Library for GPIO mode setting
*/
MFP_P30_GPIO;
P30_PUSHPULL_MODE; /* set P1.2 as PushPull output mode */
/*
For UART0 P3.1 as TXD output setting use VCOM function.
* include uart.c in Library Setting for UART0
*/
MFP_P31_UART0_TXD; /* UART0 TXD use P31 */
P31_QUASI_MODE; /* set P3.1 Quasi mode for UART0 trasnfer */
UART_Open(24000000,UART0_Timer1,115200); /* Open UART0 use timer1 as baudrate generate and baud rate = 115200 */
ENABLE_UART0_PRINTF; /* to use printf function, need set TI first. */
/* Setting Pin interrupt initial
* include pinint.c in Library for GPIO mode setting
*/
MFP_P25_GPIO;
P25_INPUT_MODE; /* set P2.5 as input output mode */
GPIO_Pull_Enable(Port2,SET_BIT5,PullUp);
GPIO_EnableInt(PIT0,FALLING,EDGE,2,5); /* Setting pin intterrupt channel 0 as P2.5 falling edge trigger. */
MFP_P32_GPIO;
P32_INPUT_MODE; /* set P3.2 as input output mode */
GPIO_Pull_Enable(Port3,SET_BIT2,PullDown);
GPIO_EnableInt(PIT3,RISING,EDGE,3,2); /* Setting pin intterrupt channel 3 as P3.2 rising edge trigger. */
ENABLE_GLOBAL_INTERRUPT;
while(1);
}
|