LCP1114 Capture Timer1

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LCP1114 Capture Timer1

299 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Thu Jan 29 02:19:40 MST 2015
Hello,

I am trying to capture the value of the timer32_1 every rising edge from CT32B1_CAP0.
This is my config:

#define CONF_COUNTER_32_B1\
LPC_IOCON->R_PIO1_0    = 0x00C3;    /* */\
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<10);    /*enable clock to CT32B1 (sec. 3.5.14)*/\
\
LPC_TMR32B1->MCR= 0x0000;/*disable all operation with match registers*/\
LPC_TMR32B1->PWMC= 0x00;/*disable all operation with pwm mode*/\
LPC_TMR32B1->EMR= 0x00;/**/\
LPC_TMR32B1->CCR = 0x05;/*capture on CT32B1 rising edge and interrupt on CT32B1 event*/\
LPC_TMR32B1->CTCR = 0x00;/*timer mode: every rising PCLK edge*/\
\
\
/* Enable the CT32B1 Interrupt */\
NVIC_EnableIRQ(TIMER_32_1_IRQn);


The interrupt jumps but the CR0 value is always 0.
And the IR value is 0x16.

I don't know why CR0 has not value. And Why IR is 0x16 when it must be 0x10.
Labels (1)
0 Kudos
2 Replies

245 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Mon Feb 09 14:21:45 MST 2015
I used this code
                LDR R3,=LPC_CT32B1_BASE
                LDR R2,=479
                STR R2,[R3,PR]                             @ prescale ÷480 - 10µs period
                MOVS R2,#3
                STR R2,[R3,CCR]                            @ capture on both edges
                MOVS R2,#1
                STR R2,[R3,TCR]                            @ enable counter


1 instead of 3 in the CCR will capture the rising edge only, 2 will capture the falling edge only.

Where's your signal coming from? Is it a nice sharp edge?
If you get zero in CR0 it could be that there is some jitter and there are multiple triggers on the edge.
If so, you need to turn on the hysteresis for that pin, or add a Schmidt trigger.

                LDR R3,=LPC_IOCON_BASE            
                MOVS R2,#0xE3
                STR R2,[R3,PIO1_0]                         @ pin 33  = CT32B1_CAP0
  

turns on the hysteresis.
0 Kudos

245 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Fri Jan 30 07:15:38 MST 2015
Could be useful to show you complete (timer init and interrupt handler) code (in CODE tags)  :~ 
0 Kudos