11 Replies Latest reply on Jul 8, 2015 10:31 AM by user_13484954

    Bootloadable not waking on GPIO interrupt


      I am having a problem whereby my application code is running really slowly because the device is sleeping during the disconnect interval and not waking when my GPIO pin is active.


      I have raised a case for this but not heard back for 3 days.


      I created an example to demonstrate.


      The attached is the HID keyboard bootloader/bootloadable project with the following mods:


      I moved a few pin assignments to pins which are accessible on the BLE pioneer board. 


      The original "enter bootloader" pushbutton which has a wakeup interrupt configured I have re-assigned as a plain GPIO input.


      The green LED I have re-assigned as a "sleeping" LED.


      The "bootloading" LED I have moved to a plain GPIO and activate it once per pass of the main loop. This needs to be connected to the interrupt pin, so P2[1] needs to be linked to P2[0] on the board.


      When the bootloadable is run, the green LED glows brightly indicating the code is spending most of its time asleep. If the link from P2[0] to P2[1] is connected/disconnected there is no difference. A scope confirms P2[1] is pulsing and this should be causing a wake interrupt every pass of the loop.


      In the main loop, if the 2 sleep API calls are commented out, the green LED glows dimly, indicating the code is no longer spending time asleep. But of couse removing sleep completely is not an option.


      I am pretty sure this issue is specific to the bootloader/bootloadable setup. I did a quick check using a non-bootloadable project and it seemed to work properly.

        • 1. Re: Bootloadable not waking on GPIO interrupt

           Are you clearing the Pin interrupts in the associated Pin ISR?

          • 2. Re: Bootloadable not waking on GPIO interrupt

             Yes I added a "Clearpending" in the ISR. 


            But the problem might be that the interrupt is not going to the place I think it is, owing to the structure of the bootloader.

            • 3. Re: Bootloadable not waking on GPIO interrupt

               Found this still wont work in a standard non-bootloadable project.


              In the attached, no wake when P2-0 activated. In fact worse than that the code usually stops working completely when this pin is activated.

              • 4. Re: Bootloadable not waking on GPIO interrupt

                From -     http://www.cypress.com/?rID=95069     AN90799 - PSoC® 4 Interrupts














                Regards, Dana.

                • 5. Re: Bootloadable not waking on GPIO interrupt

                   Thanks, that confirms I have it all configured correctly.


                  It does not explain why the interrupt not waking the CPU though. The examples dont show a sleep/wake scenario.

                  • 6. Re: Bootloadable not waking on GPIO interrupt

                    I got this to work outside of the bootloader but still not working in bootloader.


                    The documentation suggests a number of options but in the end there is only one configuration which works ie:


                    The Interrupt component must be used, using the pin interrupt alone does not work. This must be connected to the ISR connection from the pin icon.


                    The interrupt component must not be configured as "level" (despite the app note example having it configured this way) it must be "Derived" and the pin interrupt set to falling or rising.


                    The interrupt component interrupt must be started during init.


                    In the ISR the PIN interrupt must be cleared (not the interrupt component interrupt)


                    Before sleeping the PIN interrupt must be cleared and the interrupt component interrupt must be enabled.


                    The  interrupt component interrupt  must be disabled when not sleeping.




                    This all works but when I transfer the same config to a bootloadable the code sticks in the ISR for ever.


                    EDIT: Now got this to work in the bootloadable! What a struggle.


                    It appears that the pins and interrupts need to be defined in the bootloader not the bootloadable. Then a StartEX can be done in the bootloadable to relocate the ISR into the bootloadable.


                    There is a huge omission in all the bootloader documentation. When a function which exists in the bootloader is called from the bootloadable simply defining it as an "extern" in SharedProjectAPI.h (as the docs state) is not enough. A file in the Bootloader "scripts" folder called "symbol_list.txt" needs to be edited to add it, otherwise it will not be found by the compiler. 

                    • 7. Re: Bootloadable not waking on GPIO interrupt

                      Can you please upload your complete project again? In the first workspace bundle I could not see any handlings with the pin-interrupt.





                      • 8. Re: Bootloadable not waking on GPIO interrupt

                        I thought I would post the final resolution to this issue which I eventually found after many days in case anyone else falls into the trap.


                        In fact no interrupts were working in the bootloadable which I discovered when adding a timer interrupt.The reason is this: In the bootloadable there is a function "InitializeBootloaderSRAM". If this is called after any interrupts are defined, it overwrites the bootloadable vector table with the one from the bootloader so any defined vectors are reset back to the bootloader default handler which is an infinite loop.

                        • 9. Re: Bootloadable not waking on GPIO interrupt

                          Andy, thank you very much sharing your experience with us! To get it quite clear for me: Where was the call to InitializeBootloaderSRAM() placed? Did you insert that or was it called accidently??





                          • 10. Re: Bootloadable not waking on GPIO interrupt

                             The call is in the example bootloader/bootloadable projects in "main".


                            I was using this as a base but I put the definition of the timer and GPIO interrupts before it instead of after it. This call must be the very first line in "main".


                            The problem caused the code to jump back into the bootloader code from the bootloadable on any interrupt so was not obvious what was going on in the debugger as it would get lost.

                            • 11. Re: Bootloadable not waking on GPIO interrupt

                               For info:


                              Another issue with the bootloader which I raised a case for and has now been resolved:


                              Any component placed in the bootloadable schematic would be non-functional unless also placed in the bootloader schematic.


                              The workaround from Cypress:


                              Comment out or remove line#82 (Bootloader__libc_init_array();) of BtldrSramInit.c file in the bootloadable project. 


                              This will be fixed in Creator 3.2 SP1