Best way to have more than one WKUP GPIO pins?

User can not catch wakeup interrupt from user code with shutdown mode. It is happened in native firmware.

The interrupt event you saw, it is not after shutdown. It is before new shutdown, after the device woke up and reset already.

OK ā€¦ but, how do I know which pin generated the Interrupt ?

I can try to read register tomorrow. I dont think it is hard.

Looks like PWR_SR1 has the source of wakeup.
Iā€™m not sure how to read it.

Thanks for looking into this !

     ....
     const uint PWR_SR1 = 0x40000000U + 0x7000U + 0x10;
     const uint PWR_SCR = 0x40000000U + 0x7000U + 0x18;

     // Read wakeup source -> Read must be done before clear or it will be set to 0.
     var wakeupSource  = Marshal.ReadInt32((IntPtr)PWR_SR1, 0);

     if ((wakeupSource & (1 << 0)) != 0)
     {
         Debug.WriteLine("Wk by PA0");
     }
     else if ((wakeupSource & (1 << 3)) != 0)
     {
         Debug.WriteLine("Wk by PA2");

     }

     // Clear wakeup flag after read PWR_SR1 above to enter new shutdown
     Marshal.WriteInt32((IntPtr)PWR_SCR, 0x7FFFFFFF); 
    // Enter Shutdown
   .......
1 Like