configurar entrada de captura (input capture) CIAA

114 views
Skip to first unread message

marco

unread,
Oct 1, 2016, 7:31:52 PM10/1/16
to Embebidos32

Hola , que tal?

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
#define INPUT                            0
#define OUTPUT                        1
#define ON                                  1
#define OFF                                0

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;
}

Fernando Lichtschein

unread,
Oct 1, 2016, 10:00:27 PM10/1/16
to embebidos32@
No veo que estés habilitando el clock para el timer.

--
-- Recibiste este mensaje porque estás suscripto al Grupo Google Embebidos32. Para postear en este grupo, escribe un email a embeb...@googlegroups.com. Para des-suscribirte, envía un email a embebidos32+unsubscribe@googlegroups.com. Para más opciones, visita el sitio del grupo en https://groups.google.com/d/forum/embebidos32?hl=es
---
Has recibido este mensaje porque estás suscrito al grupo "Embebidos32" de Grupos de Google.
Para anular la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a embebidos32+unsubscribe@googlegroups.com.
Para acceder a más opciones, visita https://groups.google.com/d/optout.

marco

unread,
Oct 3, 2016, 9:04:05 AM10/3/16
to Embebidos32
Creo que es esto es a lo que te refirías:

  Chip_Clock_Enable(CLK_MX_TIMER0);

pero de igual manera me sigue sin funcionar.

marco

unread,
Oct 21, 2016, 4:48:19 PM10/21/16
to Embebidos32
EL inconveniente se encontraba en la selección del modo de funcionamiento del pint del imput capture. (Chip_SCU_PinMuxSet(IC_SCU_PORT, IC_SCU_PIN,  SCU_MODE_FUNC4); )
Se debe activar la función de MD_EZI (input buffer enable)
Gracias , Saludos

Reply all
Reply to author
Forward
0 new messages