kdsk - how to access hardware, say GPIO, inside and outside interrupts?

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

kdsk - how to access hardware, say GPIO, inside and outside interrupts?

658 Views
petero
Contributor I

Using ksdk on a Cortex M4. Using kdsk if your accessing hardware from inside and outside interrupts do you need to add disable and enable interrupts around the hardware access in the main thread?  see //### below

 

Like this:
void main(void)
{
  GPIO_PinInit();   //init some kdsk hardware
  enableInterruptXYZ();
  while (1)
  {
    disableInterruptXYZ();  //### need this line?
    GPIO_WritePinOutput(); //access some kdsk hardware
    enableInterruptXYZ();  //### also need this line?
    //do other stuff
  }
}

 

InterruptXYZ-Handler()
{
GPIO_WritePinOutput(); //access the same kdsk hardware
}

Labels (1)
Tags (1)
0 Kudos
3 Replies

450 Views
petero
Contributor I

Ok.  So your saying GPIO_WritePinOutput() is reentrant?  If yes, seen an documentation confirming this?

0 Kudos

450 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

i think GPIO_WritePinOutput() is reentrant function.

BR

xiangjun Rong

0 Kudos

450 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Peter,

I think it is unnecessary to disable interrupt when  you want to set or clear a GPIO pins no matter whether the setting/clearing GPIO pin is inside main loop or ISR. when you run the code GPIO_WritePinOutput(); the GPIO pin logic changes immediately.

Hope it can help you

BR

XiangJun Rong

0 Kudos