Interrupt handling while supporting bluetooth

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I'm a noob at the PSoC4BLE, but quite a bit of experience with other micros.  I'm trying to run some code at about a 20hz rate to smoothly control an external device and I'm having a hard time finding info about what kind of timing and interrupts can be supported while running the Bluetooth stack.  I started experimenting with the BLE_RGB_Power_LED code sample as a baseline.

   

I tried toggling an output pin each pass through main and found that it toggles several times quickly (750us, 200us, 3.5ms) then always sits for approx 200ms. before repeating.  This is while the PSoC is not connected to anything via bluetooth. Is this related to the GAP advertising interval?  If so, it kind of implies this is handled in a timing loop rather than via interrupt in the Bluetooth code.  After connecting via CySmart, the 200ms period changes to about 65ms. which is maybe the Peripheral connection interval.  

   

I added generic interrupt code to the project based on the Cypress PSoC 4 Interrupts doc AN90799 which uses a timer interupt (Project1_Timer). However this interrupt doesn't appear to be activated and I'm guessing it conflicts with something the bluetooth stack is doing.  

   

So I'm hoping for some ideas as to what to what approach to take.  The main loop timing interval is too erratic and slow to use, but I don't know what approach to use for an interrupt solution while bluetooth code is running.  Any help would be much appreciated.

0 Likes
1 Solution
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Its perfectly fine to run interrupts in parallel with the BLE stack. 20Hz is not a high rate.

   

Use a timer block with an ISR to create a fixed interval. In this ISR you can do short calculations. For anything longer, set a flag and react to it in the main loop.

   

If you have problems, maybe post your project so we can have a look (file / archive).

View solution in original post

0 Likes
1 Reply
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Its perfectly fine to run interrupts in parallel with the BLE stack. 20Hz is not a high rate.

   

Use a timer block with an ISR to create a fixed interval. In this ISR you can do short calculations. For anything longer, set a flag and react to it in the main loop.

   

If you have problems, maybe post your project so we can have a look (file / archive).

0 Likes