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 needs to be linked to P2 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 to P2 is connected/disconnected there is no difference. A scope confirms P2 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.
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.
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.
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.
Can you please upload your complete project again? In the first workspace bundle I could not see any handlings with the pin-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.
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??
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.
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