Hi ramana madishetty,
1. About the capture code,
You can refer to this code:
/LED
#define LED (1 << 22)
#define LED_ON LPC_GPIO0->FIOSET=LED
#define LED_OFF LPC_GPIO0->FIOCLR=LED
#define LED_TOG LPC_GPIO0->FIOPIN^=LED
void TIMER0_IRQHandler(void)
{
uint32_t reg_val;
reg_val = LPC_TIM0->IR;
if(reg_val & (1<<4))
{
if(LPC_GPIO1->FIOPIN & (1<<26))
{
LED_ON;
}
else
{
LED_OFF;
}
LPC_TIM0->IR = (1<<4);
}
}
int main(void)
{
LPC_GPIO0->FIODIR |= LED;
volatile static int i = 0 ;
LPC_PINCON->PINSEL3 |= (3<<20);
LPC_TIM0->CCR =((1<<0)|(1<<1)|(1<<2));
LPC_TIM0->TCR = 1;
NVIC_EnableIRQ(TIMER0_IRQn);
while(1)
{
i++ ;
}
return 0 ;
}
I have test it on my side(lpcxpress 1769 board), the ISR can be entered, the capture function works OK.
I also attached the .c file which can be used in the lpcopen_2_10_keil_iar_nxp_lpcxpresso_1769 timer project directly.
I think you can let the capture ISR work at first, then add the UART code.
You can debug the code, and add the breakpoint in TIMER0_IRQHandler, when the external signal put in p1.26, rising or falling, whether the ISR breakpoint can be entered?
2. About the UART printf.
I don't recommend you add UART printf in the ISR directly, as you know, printf will consume a long time, you can define a flag, and when the IRQ happens, set that the flag, then in the main while to check this flag, and printf the UART data.
In the IRQ function, the code should as short as possible, otherwise, the other capture event will be lost.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------