LPC546xx: CT1_CAP0 on P2_0 doesn't work

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

LPC546xx: CT1_CAP0 on P2_0 doesn't work

1,229 Views
giusloq
Contributor III

I want to use P2_0 as the capture input 0 for CTIMER1, so, starting from lpcxpresso54628_hello_world SDK example for LPCXpresso EVB, I added the following code:

#define CTIMER                                  CTIMER1
#define TIMER_RESOLUTION_ns                     100

#if 0
#define PIN_CAPTURE                             2, 0
#define CAPNUM                                  0
#define IOCON_PIO_FUNC4                         4
#elif 1
#define PIN_CAPTURE                             2, 17
#define CAPNUM                                  1
#define IOCON_PIO_FUNC4                         4
#endif



	CLOCK_AttachClk(kMAIN_CLK_to_ASYNC_APB);
    IOCON_PinMuxSet(IOCON, PIN_CAPTURE,
    		IOCON_PIO_FUNC4 |
            IOCON_PIO_MODE_INACT |		/* No addition pin function */
            IOCON_PIO_INV_DI |			/* Input function is not inverted */
            IOCON_PIO_DIGITAL_EN |		/* Enables digital function */
            IOCON_PIO_INPFILT_OFF |		/* Input filter disabled */
            IOCON_PIO_OPENDRAIN_DI);    /* Open drain is disabled */
    ctimer_config_t ctmr_cfg;
	ctmr_cfg.mode = kCTIMER_TimerMode;
	ctmr_cfg.prescale = (CLOCK_GetAsyncApbClkFreq() / 1000000) * TIMER_RESOLUTION_ns / 1000 - 1;
	CTIMER_Init(CTIMER, &ctmr_cfg);

	CTIMER_SetupCapture(CTIMER,
			kCTIMER_Capture_0 + CAPNUM,
			kCTIMER_Capture_BothEdge,
			true);		/* Enable interrupt */
    NVIC_EnableIRQ(CTIMER1_IRQn);
	CTIMER_StartTimer(CTIMER);



void
CTIMER1_IRQHandler(void)
{
	CTIMER_ClearStatusFlags(CTIMER,
			CTIMER_IR_CR0INT_MASK << CAPNUM);
}

P2_0 is on pin 8 of J12 Analog In connector on EVB. When I connect alternatively this pin to GND and VCC, no interrupt is fired.

When I try to use P2_17 as CT1_CAP1 (pin 20 of J13 Digital connector) it works, the interrupt is triggered.

What's wrong with P2_0? It's a type A pin, but it seems it can be used as CT1_CAP0.

0 Kudos
Reply
4 Replies

1,224 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I have checked your code, I think you have to add the line:

CLOCK_EnableClock(kCLOCK_Iocon);

before you call the IOCON_PinMuxSet();

If you had added the line in your code, I have no idea, I think your code is correct. If you still can not fire the capture interrupt with P2_0 pin, pls try to configure the P2_0 as GPIO output mode, then set/clear the P2_0 pin, check the pin 8 of J12 Analog In connector on EVB, check if the state of the pin changes.

BR

XiangJun Rong

 

 

0 Kudos
Reply

1,222 Views
giusloq
Contributor III

I have checked your code, I think you have to add the line:

CLOCK_EnableClock(kCLOCK_Iocon);

before you call the IOCON_PinMuxSet();

Yes I have that code.

pls try to configure the P2_0 as GPIO output mode, then set/clear the P2_0 pin, check the pin 8 of J12 Analog In connector on EVB, check if the state of the pin changes.

I already made this test and it works.

0 Kudos
Reply

1,220 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

In the case, I have no idea, You have to use debugger to check the CTimer1 registers and the PIO2_0 register.

BR

XiangJun Rong

 

0 Kudos
Reply

1,213 Views
giusloq
Contributor III

In the case, I have no idea, You have to use debugger to check the CTimer1 registers and the PIO2_0 register.

Yes, I checked in Peripherals window of MCUXpresso and all the registers seem configured well.

Have you the possibility to check with one of your LPCXpresso54628 EVB and test a sample project to share with me? Many thanks.

0 Kudos
Reply