This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

manually set or trigger interrupt

Is there a way to manually trigger an interrupt?  On other micros, I simply set the interrupt flag and the interrupt triggers.  This is needed for a communication library that relies on the UART Tx interrupt to repeatedly trigger when the buffer is empty.  

The problem is getting the first interrupt to trigger.  I can manually transmit some junk byte which gets the Tx interrupt to go, but then that byte pops out of the UART pin.

  • Hi,

    Yes, set the bit in NVIC register, corresponding to the interrupt and it will be taken.

    Petrei

  • Petrei said:

    Hi,

    Yes, set the bit in NVIC register, corresponding to the interrupt and it will be taken.

    Petrei

    Ahh, ok.  I was looking in the UART section and all the interrupt bits that seemed promising were read only.  I think I found it in the datasheet now.

  • Petrei said:

    Hi,

    Yes, set the bit in NVIC register, corresponding to the interrupt and it will be taken.

    Petrei

    I thought this would be easy, but not getting the interrupt to trigger.  Is PEND0 the correct register?  The line of code is, ignoring the state of other interrupts for right now:

    HWREG(NVIC_PEND0)  = (uint32_t)INT_UART0_TM4C129;

    After this is executed, the UART0 interrupt does not execute as I'd expect.  The interrupt does execute however after I transmit a character so I know it's enabled.  I have a TM4C1294 micro by the way.

  • Hi,

    I have used this:

    HWREG(NVIC_SW_TRIG) = INT_UART0 - 16;

    but I think is also possible to avoid this - works equally well if you send a byte to UART DR register and the rest should be taken by further interrupts - as you already done,if my guess is correct.

    Petrei

  • Petrei said:

    Hi,

    I have used this:

    HWREG(NVIC_SW_TRIG) = INT_UART0 - 16;

    but I think is also possible to avoid this - works equally well if you send a byte to UART DR register and the rest should be taken by further interrupts - as you already done,if my guess is correct.

    Petrei

    Hey that works, although I don't quite understand how.  Some aspects of ARM architecture is a bit confusing I think.
    Transmitting a character out of the UART does "jumpstart" the interrupt, but since the protocol stack does everything, there isn't a very clean way to determine what the first character is the stack wants to transmit, transmit it manually, then remove it from the queue.
    In any case, problem solved.
  • jrmymllr said:
    INT_UART0 - 16;

    If I may - that's the (famed) SW Interrupt - and indeed should work.  That subtraction of 16 is "magic" - and will work with many (perhaps all) MCU peripherals.  (in fact - we use it with multiple, PWM Generators - each one generating a unique interrupt!)

    One thing to remember when using - as it's a SW generated interrupt - there's no need to "clear" such an interrupt w/in your interrupt handler...