Hello Dongho ha,
I have a IRQ IAR sample code for KEA128, this code also based on the KEXX_DRIVERS_V1.2.1_DEVD.
I have attached the KEA128_IRQ for your reference.
The code function is get the PTI0 rising IRQ interrupt. the IRQ module in KEA128 is the same as KE06, so you can refer to my source code directly.
int main (void);
void RTC_Task(void);
void IRQ_Isr(void);
unsigned int jjtest=0;
/******************************************************************************
* Global functions
******************************************************************************/
void IRQ_Isr(void)
{
IRQ->SC |= IRQ_SC_IRQACK_MASK;
}
void IRQ_Init(void)
{
SIM->PINSEL |= 0x01; //PTI0
SIM->SCGC |= SIM_SCGC_IRQ_MASK;
IRQ->SC = IRQ_SC_IRQEDG_MASK |
IRQ_SC_IRQPE_MASK |
IRQ_SC_IRQIE_MASK ;//|
//IRQ_SC_IRQMOD_MASK;
NVIC_EnableIRQ(IRQ_IRQn);
}
int main (void)
{
unsigned int test=0;
unsigned char u8Ch;
RTC_ConfigType sRTCConfig;
RTC_ConfigType *pRTCConfig = &sRTCConfig;
/* Perform processor initialization */
sysinit();
printf("\nRunning the KE06 platinum project.\n");
LED0_Init(); //red led
LED1_Init(); //green led
LED2_Init(); //blue led
LED0_Off();
LED1_Off();
LED2_Off();
/* configure RTC to 1Hz interrupt frequency */
pRTCConfig->u16ModuloValue = 9;
pRTCConfig->bInterruptEn = RTC_INTERRUPT_ENABLE; /* enable interrupt */
pRTCConfig->bClockSource = RTC_CLKSRC_1KHZ; /*clock source is 1khz*/
pRTCConfig->bClockPresaler = RTC_CLK_PRESCALER_100; /*prescaler is 100*/
RTC_SetCallback(RTC_Task);
RTC_Init(pRTCConfig);
IRQ_Init();
printf("Please enter any character which will echo...\n");
/* echo chars received from terminal */
test = jjtest;
while(1)
{
u8Ch = UART_GetChar(TERM_PORT);
UART_PutChar(TERM_PORT, u8Ch);
LED2_Toggle();
}
}
Another question, the port in default is the input, but if you want to use the GPIO input, you also need to configure GPIOx_PDIR to enable the general purpost input function.
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------