Ya hace varias semanas que intento configurar el TIMER0 de la CIAA con el objetivo que reconozca tanto un flanco ascendente como descendente desde un pin(T0_CAP3). He buscado ejemplos, leído el manual y no lo logro hacer funcionar. Adjunto el código(solo el main) por si alguien ya ha trabajado con la entrada de captura y puede detectar el error. Muchas gracias
#define TIMER_NUMBER 0
#define CAP_NUMB 3
#define TIMER0_PRESCALER 10
#define IC_SCU_PORT 1
#define IC_SCU_PIN 17
#define LPC_TIMER LPC_TIMER0
#define RGU_TIMER_RST RGU_TIMER0_RST
#define LPC_TIMER_IRQ TIMER0_IRQn
volatile uint8_t STATUS=0;
__attribute__ ((section(".after_vectors")))
void TIMER0_IRQHandler(void){
if (STATUS == 0)
STATUS=1;
else
STATUS=0;
}
int main(void)
{
SystemCoreClockUpdate();
ledConfig();
Chip_SCU_PinMuxSet(IC_SCU_PORT, IC_SCU_PIN, SCU_MODE_FUNC4);
Chip_TIMER_Init(LPC_TIMER);
LPC_GIMA->CAP0_IN[TIMER_NUMBER][CAP_NUMB] = (1<<4);
Chip_RGU_TriggerReset(RGU_TIMER_RST);
while (Chip_RGU_InReset(RGU_TIMER_RST));
Chip_TIMER_Reset(LPC_TIMER); //resetea el timer desde el propio timer
Chip_TIMER_TIMER_SetCountClockSrc(LPC_TIMER, TIMER_CAPSRC_RISING_PCLK, CAP_NUMB);
Chip_TIMER_PrescaleSet(LPC_TIMER, TIMER0_PRESCALER);/
Chip_TIMER_ClearCapture(LPC_TIMER, CAP_NUMB);
Chip_TIMER_CaptureRisingEdgeEnable(LPC_TIMER, CAP_NUMB);
Chip_TIMER_CaptureFallingEdgeEnable (LPC_TIMER, CAP_NUMB );
Chip_TIMER_CaptureEnableInt(LPC_TIMER, CAP_NUMB);/
NVIC_ClearPendingIRQ(LPC_TIMER_IRQ);
NVIC_EnableIRQ(LPC_TIMER_IRQ);
Chip_TIMER_Enable(LPC_TIMER);
while(1) {
ledSet(STATUS);//enciende el led como señal de detección de flanco
}
return 0;
}