2 Replies Latest reply on Aug 1, 2019 4:12 AM by SuMa_296631

    PSoc 6 BLE notifications work in debug but not otherwise

    SuMa_296631

      Using PSoC 5 BLE (latest version, latest version of PSoC Creator etc.) and I have (finally) managed to get an app that sends notifications.

      However it only works if I build for debug and then start a debugging session (on CM4). All I need to do in that session is to start it running and I can start and stop the notifications. (The read  function works as well.)

      However if the only change I make is to program the PSoC 6 so it runs without the debugger (i.e. no recompiling or linking - as far as I know it is the same image that is being loaded but without the debugger startup) then only the read functions work.

      The values come from an ADC that uses an ISR at the end of each scan. Inside that ISR are the calls to Cy_BLE_GATTS_WriteAttributeValueLocal and CyCLE_GATS_SendNotification.

      It seems to be that it is a timing issue with the way the applications start up between the cores (with the debugger active CM4 will start up a number of seconds after CM0; without the debugger it will be milliseconds or less) but I'm not familiar enough with the internals of BLE to know where to start tracking this down.

      Any suggestions will be appreciated.

      Susan

        • 1. Re: PSoc 6 BLE notifications work in debug but not otherwise
          ShipingW_81

          All BLE stack operation needs execution of Cy_BLE_ProcessEvents. Therefore, better not to put Cy_BLE_GATTS_WriteAttributeValueLocal and CyCLE_GATS_SendNotification in a ADC ISR. Instead, use a global flag to call the APIs in main loop.

           

          Let me know if it's the cause.

          • 2. Re: PSoc 6 BLE notifications work in debug but not otherwise
            SuMa_296631

            I think I have this worked out.

            There were two things happening: the first is a logic error on my part that was causing the 'ADC_StartConvert' function to be called repeatedly and before the scan had been completed. This caused the ISR to not ever be called.

            The second is that the debugger appears to stop the 'deep sleep' functionality - see 'Bob's comment in the 2nd to last note in Debug and Programming, why is not working after programming? .

            I did do as 'WangS_81' suggested (which I should have done anyway) but I really can't tell if this contributed or not as I don't think the ISR was ever called except when the debugger was running as (I think!) the time required for the debugger to reverse the deep sleep was probably enough time for the scan to be completed and the ISR called.

            Anyway: problem solved so thank you for your assistance.

            Susan