Bizarre state of output pin when enabling PInt0

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

Bizarre state of output pin when enabling PInt0

416 Views
asier
Contributor III

Hi,

I'm just starting with NXP's MCUs: I'm trying a simple example. I configure PIO0_10 as input pin and PIO0_1 as output. 

We have a square wave in PIO0_10 input and I want to enable PInt0 attached to this input. Then, I want to enable PInt0 interrupt and toggle the output pin PIO0_1 whenever an interrupt callback is happened.

The issue I have is that when I do "PINT_Init(PINT);" my PIO0_1 output gets a bizarre state of 1v.

Any idea what is wrong on my code ? Is there something I'm forgeting ? 

Thanks,

Asier.

I'm using LPC822.

My code is next:

#define BOARD_INITPINS_BLOQ_PORT 0U

#define BOARD_INITPINS_BLOQ_PIN 1U

void pint_intr_callback(pint_pin_int_t pintr, uint32_t pmatch_status)
{
   if (!change)
   {
      change = true;
      GPIO_PinWrite(BOARD_INITPINS_BLOQ_GPIO, BOARD_INITPINS_BLOQ_PORT, BOARD_INITPINS_BLOQ_PIN, 1);
   }
   else
   {
      change = false;
      GPIO_PinWrite(BOARD_INITPINS_BLOQ_GPIO, BOARD_INITPINS_BLOQ_PORT, BOARD_INITPINS_BLOQ_PIN, 0);
   }
}

void init_PInt(void)
{
   /* Connect trigger sources to PINT */
   SYSCON_AttachSignal(SYSCON, kPINT_PinInt0, 10);


   /* Initialize PINT */
   PINT_Init(PINT);

   /* Setup Pin Interrupt 0 for rising edge */
   PINT_PinInterruptConfig(PINT, kPINT_PinInt0, kPINT_PinIntEnableRiseEdge, pint_intr_callback);


   /* Enable callbacks for PINT0 by Index */
   PINT_EnableCallbackByIndex(PINT, kPINT_PinInt0);
}

int main(void) {
   /* Init board hardware. */
   BOARD_InitBootPins();
   BOARD_InitBootClocks();
   BOARD_InitBootPeripherals();
   init_PInt();

   while(1){

   }

   return 0;

}

Labels (1)
0 Kudos
1 Reply

328 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Asier,

I suppose that you can enter pin interrupt and execute the pint_intr_callback() function, but it appears that you can NOT toggle the PIO0_1 pin.

I suppose that you can initialize the PIO0_1 pin as GPIO pin and toggle the pin with the code:

//PIO0_1 as output
//configure PIO0_1 as output with SDK
void PIO0_1_Init(void)
{
    gpio_pin_config_t PIO0_1_config = {
        kGPIO_DigitalOutput, 0,
    };
    SYSCON->SYSAHBCLKCTRL |= 1 << 7; //enable SWM clock
        SWM0->PINENABLE0|=0x102;
        GPIO->MASK[0]&=~(0x02);
    GPIO_PortInit(GPIO, 0);
    GPIO_PinInit(GPIO, 0, 1, &PIO0_1_config);
    GPIO_PinWrite(GPIO,0,1,1);
    GPIO_PinWrite(GPIO,0,1,0);
}

   

in the the callback function, you can try to use the code:

 GPIO_PortToggle(GPIO, 0, 1u <<1);

Pls have a try.

BTW, if you can not enter PIN interrupt, pls refer to the pin interrupt example in SDK.

Hope It can help you

BR

XiangJun Rong

0 Kudos