This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unable to perform UART transfer on every Timer Interrupt

Hi All,

I am using nRF51422DK with SDK 10 and trying to communicate with an external peripheral over UART at every timer interrupt.

I have modified the ble_app_hrs example so that whenever application timer generates an event I send UART command, wait for response (approx 150 ms) and then try to receive the bytes.

To check my UART communication works fine, I performed a set of UART communication before initializing the timer and ble stack. I am able to send and receive data as desired. UART interrupt is enabled to notify completion of TX and RX data

However, when I perform the same routine within the timer event handler, the system resets and jumps back to the first function trying to reinitialize all from the start.

Can anyone let me what could be the issue?

Thank you.

Best Richard

Parents
  • I suspect that you are running code within the interrupt handler that breaks the Softdevice timing and should run in main context instead.

    My suggestion would be to only set flags in the timer interrupt handlers, then check these flags in the main while loop. If the flag is set, run the code you previously had in the interrupt handler and reset the flag e.g

    unit8_t flag = 0;
    
    void timeout_handler
    {
         flag = 1:
    }
    
    int main()
    {
    // Rest of main()       
        while()
        {
            power_manage();
        
            if( flag )
            {
                // Run code previously in timeout handler 
                flag = 0;
            }
        }
    }
    
Reply
  • I suspect that you are running code within the interrupt handler that breaks the Softdevice timing and should run in main context instead.

    My suggestion would be to only set flags in the timer interrupt handlers, then check these flags in the main while loop. If the flag is set, run the code you previously had in the interrupt handler and reset the flag e.g

    unit8_t flag = 0;
    
    void timeout_handler
    {
         flag = 1:
    }
    
    int main()
    {
    // Rest of main()       
        while()
        {
            power_manage();
        
            if( flag )
            {
                // Run code previously in timeout handler 
                flag = 0;
            }
        }
    }
    
Children
No Data
Related