LPC55S69 Ctimer2 CAP doesn't work

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

LPC55S69 Ctimer2 CAP doesn't work

Jump to solution
889 Views
qingyunliu
Contributor II

I want use Ctimer2 cap function to calculate PWM frequency.

I find the similar introduction, eg 

[1] https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC845-Pulse-width-Measurement-Using-CTI...

[2] https://www.freesion.com/article/4997763456/ the pin is P1_9, I configure it as following code, but it can not work if I press SW3(P1_9), no Ctimer2 IRQ is trigger. 

const uint32_t port1_pin9_config = (/* Pin is configured as CTIMER_INP4 */
IOCON_PIO_FUNC3 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);

IOCON_PinMuxSet(IOCON, 1U, 9U, port1_pin9_config);

can anyone show a demo on LPC55S69? or fingure out what's wrong in demo2.

Labels (1)
0 Kudos
Reply
1 Solution
863 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @qingyunliu,

Demo 2 is using MCUXpresso IDE's ConfigTools, to use and routing the pin INPUTCAPTURE0; updating the code trough ConfigTools gives the following code:

    if (Chip_GetVersion()==1)

    {

        IOCON->PIO[1][9] = ((IOCON->PIO[1][9] &

                         /* Mask bits to zero which are setting */

                         (~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))

 

                        /* Selects pin function.

                         * : PORT19 (pin 10) is configured as CT_INP4. */

                        | IOCON_PIO_FUNC(PIO1_9_FUNC_ALT3)

 

                        /* Select Digital mode.

                         * : Enable Digital mode.

                         * Digital input is enabled. */

                        | IOCON_PIO_DIGIMODE(PIO1_9_DIGIMODE_DIGITAL));

    }

    else

    {

        IOCON->PIO[1][9] = ((IOCON->PIO[1][9] &

                         /* Mask bits to zero which are setting */

                         (~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))

 

                        /* Selects pin function.

                         * : PORT19 (pin 10) is configured as CT_INP4. */

                        | IOCON_PIO_FUNC(PIO1_9_FUNC_ALT3)

 

                        /* Select Digital mode.

                         * : Enable Digital mode.

                         * Digital input is enabled. */

                        | IOCON_PIO_DIGIMODE(PIO1_9_DIGIMODE_DIGITAL));

    }

Could you please try out modifying your pin_mux.c with the previous code? 

Do not forget to modify the pin_mux.h with:

#define PIO1_9_DIGIMODE_DIGITAL 0x01u

#define PIO1_9_FUNC_ALT3 0x03u  

If you are using MCUXpresso IDE, you could try using ConfigTools to do the same routing scheme than Demo 2, as follows:

  • Click in Pins icon

RaulRomero_5-1672688255591.png

  • Search for the pin you are looking for

RaulRomero_6-1672688255593.png

  • Check the box and select the functionality you need.

RaulRomero_7-1672688255594.png

  • Update the Code (it will update pin_mux.c and pin_mux.h)

RaulRomero_8-1672688255596.png

Best regards, Raul.

View solution in original post

0 Kudos
Reply
1 Reply
864 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @qingyunliu,

Demo 2 is using MCUXpresso IDE's ConfigTools, to use and routing the pin INPUTCAPTURE0; updating the code trough ConfigTools gives the following code:

    if (Chip_GetVersion()==1)

    {

        IOCON->PIO[1][9] = ((IOCON->PIO[1][9] &

                         /* Mask bits to zero which are setting */

                         (~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))

 

                        /* Selects pin function.

                         * : PORT19 (pin 10) is configured as CT_INP4. */

                        | IOCON_PIO_FUNC(PIO1_9_FUNC_ALT3)

 

                        /* Select Digital mode.

                         * : Enable Digital mode.

                         * Digital input is enabled. */

                        | IOCON_PIO_DIGIMODE(PIO1_9_DIGIMODE_DIGITAL));

    }

    else

    {

        IOCON->PIO[1][9] = ((IOCON->PIO[1][9] &

                         /* Mask bits to zero which are setting */

                         (~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))

 

                        /* Selects pin function.

                         * : PORT19 (pin 10) is configured as CT_INP4. */

                        | IOCON_PIO_FUNC(PIO1_9_FUNC_ALT3)

 

                        /* Select Digital mode.

                         * : Enable Digital mode.

                         * Digital input is enabled. */

                        | IOCON_PIO_DIGIMODE(PIO1_9_DIGIMODE_DIGITAL));

    }

Could you please try out modifying your pin_mux.c with the previous code? 

Do not forget to modify the pin_mux.h with:

#define PIO1_9_DIGIMODE_DIGITAL 0x01u

#define PIO1_9_FUNC_ALT3 0x03u  

If you are using MCUXpresso IDE, you could try using ConfigTools to do the same routing scheme than Demo 2, as follows:

  • Click in Pins icon

RaulRomero_5-1672688255591.png

  • Search for the pin you are looking for

RaulRomero_6-1672688255593.png

  • Check the box and select the functionality you need.

RaulRomero_7-1672688255594.png

  • Update the Code (it will update pin_mux.c and pin_mux.h)

RaulRomero_8-1672688255596.png

Best regards, Raul.

0 Kudos
Reply