Simulate an Event

Hello dear Nordic.
I am wondering if I can simulate a hardware event by the software by writing any value to the event register, or in other words to create artificial interrupt trigger? Or maybe you have a special API for such a thing?

volatile uint32_t *nfc_FieldOnEvent = (volatile uint32_t *)0x4005104;
*nfc_FieldOnEvent = 1;


Best regards, Genadi.

Parents
  • Hi,

    You should be able to write '1' to the EVENT register to set the event, but it will not trigger any interrupt. The interrupt can be triggered using the NVIC_SetPendingIRQ() API. If you have defined an IRQ handler that checks the EVENT register, the event will be handled if you have written the register to '1' before triggering the interrupt.

    Note that there is a typo in your code snippet. The address should be 0x40005104.

    Best regards,
    Jørgen

  • Excuse me Jorgen, but I am afraid I closed the ticket too soon. 
    I implemented this function to my code and it works perfectly, I may see interrupt toggling. However, when I set "1" to the event register its value remains '0'. I corrected the address and added missing digit.

    Should I set it to some "magic" number to make it work?

    Looking forward to hearing from you.

  • Hi,

    I tested this now as well, but it seems that the event registers won't accept writing values of 1. I assumed that since the register is defined as read/write, it should be possible to set it to 1, but there might be some internal limitations in the HW that prevent the application from setting the register to anything other than '0'.

    This is not the intended use of the register. What do you want to achieve by setting it to 1? The peripheral will not be in the correct state if you generate a false event, so your application will likely not function properly. If you want to test part of your code that is executed when the event is generated, you may modify the interrupt handler to check another variable than the event register, that you will have full control over.

    Best regards,
    Jørgen

Reply
  • Hi,

    I tested this now as well, but it seems that the event registers won't accept writing values of 1. I assumed that since the register is defined as read/write, it should be possible to set it to 1, but there might be some internal limitations in the HW that prevent the application from setting the register to anything other than '0'.

    This is not the intended use of the register. What do you want to achieve by setting it to 1? The peripheral will not be in the correct state if you generate a false event, so your application will likely not function properly. If you want to test part of your code that is executed when the event is generated, you may modify the interrupt handler to check another variable than the event register, that you will have full control over.

    Best regards,
    Jørgen

Children
Related