Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. nRF5 action!

nRF5 action!

Scheduled Pinned Locked Moved My Project
1.9k Posts 49 Posters 631.4k Views 44 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Toyman
    wrote on last edited by Toyman
    #1107

    What's the proper way to deal with interrupts on nrf?
    Many white areas:

    • shall I use "smartsleep()" instead of usual arduino way of attaching interrupts? is it enough?
    • what pins have hardware interrupts? any?
    • what about the macro mentioned in d00016 readme?
    • how to overcome nrf51 bug of 1ma power consumption (code-wise)? Otherwise I see no reason buying nrf51 modules if they consume 1ma while sleeping

    I thoroughly read al the docs before asking!

    NeverDieN d00616D 2 Replies Last reply
    1
    • T Toyman

      What's the proper way to deal with interrupts on nrf?
      Many white areas:

      • shall I use "smartsleep()" instead of usual arduino way of attaching interrupts? is it enough?
      • what pins have hardware interrupts? any?
      • what about the macro mentioned in d00016 readme?
      • how to overcome nrf51 bug of 1ma power consumption (code-wise)? Otherwise I see no reason buying nrf51 modules if they consume 1ma while sleeping

      I thoroughly read al the docs before asking!

      NeverDieN Offline
      NeverDieN Offline
      NeverDie
      Hero Member
      wrote on last edited by NeverDie
      #1108

      @Toyman said in nRF5 Bluetooth action!:

      What's the proper way to deal with interrupts on nrf?

      Welcome to the bleeding edge. I'm only aware of the one way, which is how @d00616 does it in his example code above. It seems like this part of the code is still (?) under development. For instance, the HW supports multiple interrupts being active at the same time, whereas the current code seems to support at most one interrupt.

      T 1 Reply Last reply
      0
      • NeverDieN NeverDie

        @Toyman said in nRF5 Bluetooth action!:

        What's the proper way to deal with interrupts on nrf?

        Welcome to the bleeding edge. I'm only aware of the one way, which is how @d00616 does it in his example code above. It seems like this part of the code is still (?) under development. For instance, the HW supports multiple interrupts being active at the same time, whereas the current code seems to support at most one interrupt.

        T Offline
        T Offline
        Toyman
        wrote on last edited by Toyman
        #1109

        @NeverDie wait, d00616 code is basically an extension of Sandeep's. The Sandeep's code (should) supports 8 interupts for nrf52 and 4 - for nrf51.
        At least, that's what I conclude from here
        Assuming it works, the next question is: can I put just ANY pin into attachinterrupt() function or not?

        1 Reply Last reply
        1
        • NeverDieN Offline
          NeverDieN Offline
          NeverDie
          Hero Member
          wrote on last edited by
          #1110

          I made this adapter to aid with collecting serial debug output from the last two nRF5 breakout boards:
          https://www.openhardware.io/view/484/IDC-10-pin-ARM-debug-adapter

          1 Reply Last reply
          0
          • T Toyman

            What's the proper way to deal with interrupts on nrf?
            Many white areas:

            • shall I use "smartsleep()" instead of usual arduino way of attaching interrupts? is it enough?
            • what pins have hardware interrupts? any?
            • what about the macro mentioned in d00016 readme?
            • how to overcome nrf51 bug of 1ma power consumption (code-wise)? Otherwise I see no reason buying nrf51 modules if they consume 1ma while sleeping

            I thoroughly read al the docs before asking!

            d00616D Offline
            d00616D Offline
            d00616
            Contest Winner
            wrote on last edited by
            #1111

            @Toyman said in nRF5 Bluetooth action!:

            What's the proper way to deal with interrupts on nrf?
            Many white areas:

            what pins have hardware interrupts? any?

            There is an limit in the number of monitored pins but not which pins are monitored.

            what about the macro mentioned in d00016 readme?

            This macro is required on NRF52 to read back event registers in interrupts. This clears the cache.

            how to overcome nrf51 bug of 1ma power consumption (code-wise)?
            Otherwise I see no reason buying nrf51 modules if they consume 1ma while sleeping

            This depends on the nRF51 chip release. The first available chip release has this type of bug. I prefer nRF52 because the chip is much more flexible with better radio characteristics.

            The flexibility of nRF5 MCUs starts with the interrupt vector in RAM. This allows to add bootloaders without adding latency or you can replace interrupts which are predefined in the arduino-nrf5 software.

            NeverDieN 1 Reply Last reply
            0
            • d00616D d00616

              @Toyman said in nRF5 Bluetooth action!:

              What's the proper way to deal with interrupts on nrf?
              Many white areas:

              what pins have hardware interrupts? any?

              There is an limit in the number of monitored pins but not which pins are monitored.

              what about the macro mentioned in d00016 readme?

              This macro is required on NRF52 to read back event registers in interrupts. This clears the cache.

              how to overcome nrf51 bug of 1ma power consumption (code-wise)?
              Otherwise I see no reason buying nrf51 modules if they consume 1ma while sleeping

              This depends on the nRF51 chip release. The first available chip release has this type of bug. I prefer nRF52 because the chip is much more flexible with better radio characteristics.

              The flexibility of nRF5 MCUs starts with the interrupt vector in RAM. This allows to add bootloaders without adding latency or you can replace interrupts which are predefined in the arduino-nrf5 software.

              NeverDieN Offline
              NeverDieN Offline
              NeverDie
              Hero Member
              wrote on last edited by
              #1112

              @d00616 said in nRF5 Bluetooth action!:

              The first available chip release has this type of bug.

              So, it's a hardware bug then? i.e. nothing can really be done about it for that chip release?

              d00616D 1 Reply Last reply
              0
              • NeverDieN NeverDie

                @d00616 said in nRF5 Bluetooth action!:

                The first available chip release has this type of bug.

                So, it's a hardware bug then? i.e. nothing can really be done about it for that chip release?

                d00616D Offline
                d00616D Offline
                d00616
                Contest Winner
                wrote on last edited by
                #1113

                @NeverDie said in nRF5 Bluetooth action!:

                @d00616 said in nRF5 Bluetooth action!:

                The first available chip release has this type of bug.

                So, it's a hardware bug then? i.e. nothing can really be done about it for that chip release?

                There is a second method via GPIO -> pin sense for interrupt detection. This method requires less power, but you have to detect which pin is changed in software. Simulating a pin change interrupt is more complicated as detecting high or low level. I have started to do some researches and tests, but in my opinion it's to much work to support these outdated chip variants.

                T 1 Reply Last reply
                0
                • NeverDieN Offline
                  NeverDieN Offline
                  NeverDie
                  Hero Member
                  wrote on last edited by
                  #1114

                  Motivated by the above, I just now did some current tests on the nRF52832 and found that:

                  1. Going directly to an RTC sleep after powerup consumes 2.2ua.
                  2. Enabling DCDC doesn't increase that.
                  3. Nor does blinking an LED and then putting that pin into a disconnected state (D0) before sleep.

                  HOWEVER,
                  4. Activating Serial using Serial.begin(..) before sleep causes the current drain during sleep to rise to around 10.8ua. That was surprising to me, because this code in hwSleep(..) seems geared toward turning OFF serial prior to sleep:

                    // Idle serial device
                    NRF_UART0->TASKS_STOPRX = 1;
                    NRF_UART0->TASKS_STOPTX = 1;
                    NRF_UART0->TASKS_SUSPEND = 1;
                  

                  So, I guess more is needed there?

                  T 1 Reply Last reply
                  0
                  • d00616D d00616

                    @NeverDie said in nRF5 Bluetooth action!:

                    @d00616 said in nRF5 Bluetooth action!:

                    The first available chip release has this type of bug.

                    So, it's a hardware bug then? i.e. nothing can really be done about it for that chip release?

                    There is a second method via GPIO -> pin sense for interrupt detection. This method requires less power, but you have to detect which pin is changed in software. Simulating a pin change interrupt is more complicated as detecting high or low level. I have started to do some researches and tests, but in my opinion it's to much work to support these outdated chip variants.

                    T Offline
                    T Offline
                    Toyman
                    wrote on last edited by
                    #1115

                    @d00616 thx. How do I use the macro? Just put in ISR?
                    Regarding the bug: if read the docs correctly, all nrf51 have the bug :-(

                    d00616D 1 Reply Last reply
                    0
                    • NeverDieN NeverDie

                      Motivated by the above, I just now did some current tests on the nRF52832 and found that:

                      1. Going directly to an RTC sleep after powerup consumes 2.2ua.
                      2. Enabling DCDC doesn't increase that.
                      3. Nor does blinking an LED and then putting that pin into a disconnected state (D0) before sleep.

                      HOWEVER,
                      4. Activating Serial using Serial.begin(..) before sleep causes the current drain during sleep to rise to around 10.8ua. That was surprising to me, because this code in hwSleep(..) seems geared toward turning OFF serial prior to sleep:

                        // Idle serial device
                        NRF_UART0->TASKS_STOPRX = 1;
                        NRF_UART0->TASKS_STOPTX = 1;
                        NRF_UART0->TASKS_SUSPEND = 1;
                      

                      So, I guess more is needed there?

                      T Offline
                      T Offline
                      Toyman
                      wrote on last edited by
                      #1116

                      @NeverDie do you use hwSleep() instead of sleep()?

                      NeverDieN 1 Reply Last reply
                      0
                      • T Toyman

                        @NeverDie do you use hwSleep() instead of sleep()?

                        NeverDieN Offline
                        NeverDieN Offline
                        NeverDie
                        Hero Member
                        wrote on last edited by
                        #1117

                        @Toyman said in nRF5 Bluetooth action!:

                        @NeverDie do you use hwSleep() instead of sleep()?

                        Yes.

                        1 Reply Last reply
                        0
                        • NeverDieN Offline
                          NeverDieN Offline
                          NeverDie
                          Hero Member
                          wrote on last edited by
                          #1118

                          OK, I found that adding:

                            NRF_UART0->ENABLE=0;  //disable UART0
                          

                          brings the current consumption back down to 2.2ua during sleep. :)

                          T d00616D 2 Replies Last reply
                          3
                          • NeverDieN NeverDie

                            OK, I found that adding:

                              NRF_UART0->ENABLE=0;  //disable UART0
                            

                            brings the current consumption back down to 2.2ua during sleep. :)

                            T Offline
                            T Offline
                            Toyman
                            wrote on last edited by
                            #1119

                            @NeverDie should it be placed just before hwSleep()?

                            NeverDieN 1 Reply Last reply
                            0
                            • T Toyman

                              @NeverDie should it be placed just before hwSleep()?

                              NeverDieN Offline
                              NeverDieN Offline
                              NeverDie
                              Hero Member
                              wrote on last edited by NeverDie
                              #1120

                              @Toyman said in nRF5 Bluetooth action!:

                              @NeverDie should it be placed just before hwSleep()?

                              It's just a possible preliminary piece of the solution, because you'll need to renable UART0 after waking up from sleep. I haven't tested to see whether Serial.print(..) still works after re-enabling, or whether it needs to be re-initialized. Those are details yet to be sorted.

                              Or, maybe there's some other way of doing it. At this point, I'm just reporting my finding and tossing it out there as a tantalizing possibility.

                              1 Reply Last reply
                              0
                              • T Toyman

                                @d00616 thx. How do I use the macro? Just put in ISR?
                                Regarding the bug: if read the docs correctly, all nrf51 have the bug :-(

                                d00616D Offline
                                d00616D Offline
                                d00616
                                Contest Winner
                                wrote on last edited by
                                #1121

                                @Toyman said in nRF5 Bluetooth action!:

                                @d00616 thx. How do I use the macro? Just put in ISR?

                                Yes. Give the event register as parameter.

                                Regarding the bug: if read the docs correctly, all nrf51 have the bug

                                This bug is listed as PAN#39 and fixed at the end of 2014.

                                T 1 Reply Last reply
                                0
                                • NeverDieN NeverDie

                                  OK, I found that adding:

                                    NRF_UART0->ENABLE=0;  //disable UART0
                                  

                                  brings the current consumption back down to 2.2ua during sleep. :)

                                  d00616D Offline
                                  d00616D Offline
                                  d00616
                                  Contest Winner
                                  wrote on last edited by d00616
                                  #1122

                                  @NeverDie said in nRF5 Bluetooth action!:

                                  OK, I found that adding:
                                  NRF_UART0->ENABLE=0; //disable UART0

                                  brings the current consumption back down to 2.2ua during sleep.

                                  Great work. Are you able to build an Pull Request fixing this? This Pull request should also be tested in the condition with a disabled serial port.

                                  If you need help, please ask. I do the reviews.

                                  NeverDieN 1 Reply Last reply
                                  0
                                  • d00616D d00616

                                    @Toyman said in nRF5 Bluetooth action!:

                                    @d00616 thx. How do I use the macro? Just put in ISR?

                                    Yes. Give the event register as parameter.

                                    Regarding the bug: if read the docs correctly, all nrf51 have the bug

                                    This bug is listed as PAN#39 and fixed at the end of 2014.

                                    T Offline
                                    T Offline
                                    Toyman
                                    wrote on last edited by
                                    #1123

                                    @d00616 said in nRF5 Bluetooth action!:

                                    Yes. Give the event register as parameter.

                                    so, if I have an intterupt atached to pin 1, what shall i put into ISR?
                                    NRF_RESET_EVENT....;
                                    Sorry for dumb questions, this is completely new to me.

                                    d00616D 1 Reply Last reply
                                    0
                                    • d00616D d00616

                                      @NeverDie said in nRF5 Bluetooth action!:

                                      OK, I found that adding:
                                      NRF_UART0->ENABLE=0; //disable UART0

                                      brings the current consumption back down to 2.2ua during sleep.

                                      Great work. Are you able to build an Pull Request fixing this? This Pull request should also be tested in the condition with a disabled serial port.

                                      If you need help, please ask. I do the reviews.

                                      NeverDieN Offline
                                      NeverDieN Offline
                                      NeverDie
                                      Hero Member
                                      wrote on last edited by
                                      #1124

                                      @d00616 said in nRF5 Bluetooth action!:

                                      If you need help, please ask.

                                      What is it that I submit? A diff file or something? And I'm guessing I do it through github?

                                      NeverDieN d00616D 2 Replies Last reply
                                      0
                                      • NeverDieN NeverDie

                                        @d00616 said in nRF5 Bluetooth action!:

                                        If you need help, please ask.

                                        What is it that I submit? A diff file or something? And I'm guessing I do it through github?

                                        NeverDieN Offline
                                        NeverDieN Offline
                                        NeverDie
                                        Hero Member
                                        wrote on last edited by NeverDie
                                        #1125

                                        Just re-enabling the UART isn't enough. Nor are the existing UART related instructions after a wake-up, if UART0 was disabled. It seems to require a re-initialization. Another Serial.begin(BAUDRATE) after wake-up does work. However, I should point out that doing that isn't free, as it adds to wake-up time. So, you may wish to add another "level" of sleep, one which saves more energy while sleeping but at the cost of a longer wake-up. Moreover, the energy consumed during the longer wakeup isn't free either, so if the sleeps are very short, you could lose more energy for using it than not. One may, therefore, also want to calculate the breakeven point to provide guidance on when to use which level of sleep.

                                        In short, this is more than a simple fix, and the software architect probably needs to consider the bigger picture in order to craft the best solution.

                                        1 Reply Last reply
                                        0
                                        • T Offline
                                          T Offline
                                          Toyman
                                          wrote on last edited by Toyman
                                          #1126

                                          Guys,

                                          Have you seen this?

                                          Note, that our beloved ebyte is not there, but PTR9618PA is

                                          NeverDieN 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          16

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular