This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Central device abruptly disconnects

Hi,

I have a peripheral connected to CC254x. And whenever data is ready it generates interrupt. On this interrupt I am reading data from that peripheral and collecting it. When sufficient data is collected i.e. 20 bytes, I send it over BLE in the Interrupt Service Routine (ISR) itself. But in this case it disconnects abruptly from the central device after some time.

But if I set the event, after collecting sufficient data, and send the data when event occurs then it runs perfectly fine.

Has anybody faced this type of issue?

Any help is appreciated. 

Thanks,

Dhaval

  • Hi Dhaval,

    Never do processing or call application functionality from an ISR directly. ISRs have been designed to quickly response and schedule event for "later" processing to be ready if a new ISR is triggered. By later could mean very short time (milliseconds) but still allowing further ISRs to trigger. Setting an event is the right method. 

    Best Regards

    Joakim

  • Hi Dhaval,

    As JoaKim mentioned don't do your processing in ISR. ISR have the highest priority in the system and hence does not allow the stack threads to run on time which causes the radio to not respond to messages sent by central device. Just  post an event in ISR(event priority should be lower to stack events priority) and the OSAL will take care of scheduling the event whenever other important events are not pending to be executed.

    Regards,

    Arun

  • Thanks Joakim and Arun for your reply.

    Do you mean that I can't send data over BLE from SR itself? I want to do that to send the data as soon as I get it. So instead of setting the Timer Event, I want to send data directly from ISR.

  • Hi,

    For sending data, you would be calling the setParamter call in profile. You can post an event in your ISR for this which gets triggered once the ISR exits. This event can call the setParameter call. The latency (for data exchange) observed should depend more on your connection interval than which event/ISR calls the setParameter function. 

    For the system to run fine, the stack threads/events need to be of highest priority. But ISR are always of higher priority hence if you execute processing of data from ISR, then stack threads wont get time to run.

    Regards,

    Arun

  • Hi Arun ,

    I added uart function to simpleBLEperipheral project . In this i initialised uart manually( configured U1CSR and U1UCR registers and Port1 pins) and wrote send and receive functions by using polling method ( I am not using any hal_uart.c and hal_uart.h files) . when i call send or receive functions in any where in the program it causing for disconnect problem ( my peripheral is disconnecting from central) . after doing research i observed that the after completion of the Event period the disconnection is happening . can any one suggest why it is happening like this