Home arrow Support arrow Forums

Luminary Micro Forums

<< Start < Prev 1 2 Next > End >>

dereksoftstuff

Expert Boarder

2008/10/30 04:26

Re:Force an interrupt by software

I'm working on a port Simulator, and use the following code to generate interrupts on individual pins on a specific port.
This gives complete control to the pin level.
Note there are LMI warnings in the docs, about reprogramming the JTAG port pins - so avoid those pins.

Note that the 2 pins params are actually bit packed bytes, 8 bits -> 8 pins.

Code:

  void GPIOSetPins(UINT portUINT pinsToTriggerUINT pinsInUse) {                   HWREG(port GPIO_O_DIR) |= pinsInUse;         // outputs   ( = 1)     HWREG(port GPIO_O_AFSEL) &= ~pinsToTrigger;      // software control ( = 0)          GPIOWrite(portpinsInUse0); // clear for multi pins per port and part updates     GPIOWrite(portpinsToTriggerpinsToTrigger);         HWREG(port GPIO_O_DIR) &= ~pinsToTrigger;         // inputs ( = 0)   }



You should call this function just before generating the port interrupt as you do now. So that on entry to the GPIO port ISR, the appropriate pins will be asserted, and you can check those as normal (and clear) : -



Code:

      if (GPIORead(GPIO_PORTA_BASEGPIO_PIN_7)) { ...

login or register to reply

hauensts

Senior Boarder

2008/10/31 07:33

Re:Force an interrupt by software

Ok, I'm not sure that I have understood your code, but will think about that.
In the moment I use an additional variable that includes the interrupts flags. If the interrupt occurs, I read out this variable and handle the flags.

Force the interrupt:

Code:

  interruptFlags GPIO_PULSE_VL GPIO_PULSE_VR GPIO_PULSE_HL GPIO_PULSE_HR; HWREG(NVIC_SW_TRIG) = INT_GPIOD 16;



Interrupt handler:
Code:

  cTemp = ( char)GPIOPinIntStatusGPIO_PORTD_BASEtrue);      GPIOPinIntClearGPIO_PORTD_BASEcTemp); if( interruptFlags) {   cTemp |= interruptFlags;// Force specific Interrupts    interruptFlags 0; } if( cTemp GPIO_PULSE_VL) {   .   .   .

login or register to reply
<< Start < Prev 1 2 Next > End >>