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.

CC2640R2F: Crash in event after while

Part Number: CC2640R2F

Hi , I am new to RTOS and I have problem with crash in event , i read 250 sample with ADCBUF with periodic  event and print with UART ,i, get same value and after 3 period code is crash and need to reset , how can i find my problem ? (i use CCS ide)

  • Hello Vahid Javadi,

    I hope you are well. To investigate further could you provide what SDK (version) you are using, as well as CCS version, and what example you are experiencing a problem with (and if you modified code within it).  Are you using a custom board, or the evaluation board?

    Did you try to place breakpoints in the code, and step through to see what's going wrong? 

    For resources to look into to get familiar with RTOS:

    Reference: adcbufcontinuous readme

    Reference: ADCBufCC26XX.h File Reference (ti.com) 

    Reference: BLE-Stack Debugging Guide (ti.com)

    Reference: TI-RTOS Kernel User's Guide

    Thanks,
    Alex F

  • Hello Alex 

    Thanks for your answer. i use simple_peripheral example with ccs 12.4.0.00007 and SDK version is 5_30_00_03 . I found out this function crash the event and in second period just one adc value change : 

    ADCBuf_Params_init(&adcparams);
    adcparams.returnMode = ADCBuf_RETURN_MODE_BLOCKING;
    adcparams.recurrenceMode = ADCBuf_RECURRENCE_MODE_ONE_SHOT;
    adcparams.samplingFrequency = 200000;
    MyAdcBuf = ADCBuf_open(Board_ADCBUF0, &adcparams);


    conversion.samplesRequestedCount = 250;
    conversion.sampleBuffer = sampleBuffer1;
    conversion.adcChannel = 1;

    static void detectLongPeaks(uint16_t size, uint16_t threshold, uint16_t minWidth) {
    	static int peakStart = -1,n=0;
        static uint16_t peakWidth = 0;
        static  uint16_t maxPeak=0;
        static uint16_t maxPeakLocation=0;
    	static uint16_t j=0,i;
    	maxPeakLocation=0;
    	maxPeak=0;
    	peakWidth = 0;
    	j=0;
    	peakStart = -1;
    	memset((uint16*)PeakTimeDiff,0,250);
        for (i = 10; i < size; i++) {
            if (adcbuf[i] > threshold) {
                if (peakStart == -1 && (adcbuf[i]-threshold)>30 && (adcbuf[i]-adcbuf[i-1])>20) {
                    peakStart = i;
                    peakWidth = 1;
                    maxPeak=adcbuf[i];
                    maxPeakLocation=i;
                    UART_write(uart,"[ ", 2);
                }else if(peakStart != -1 && (maxPeak-sampleBuffer1[i])>30)
                {
                	  PeakTimeDiff[j++]=maxPeakLocation;
                	  peakStart = -1;
                	  peakWidth = 0;
                	  maxPeakLocation=0;
                	  maxPeak=0;
                	 UART_write(uart,"] ", 2);
    
                }else {
                    peakWidth++;
                    if(adcbuf[i]>maxPeak)
                    {
                    	 maxPeak=adcbuf[i];
                    	 maxPeakLocation=i;
                    }
                }
            } else {
                if (peakStart != -1) {
                	PeakTimeDiff[j++]=maxPeakLocation;
                	  peakStart = -1;
                	  peakWidth = 0;
                	  maxPeakLocation=0;
                	  maxPeak=0;
                	  UART_write(uart,"] ", 2);
                }
    
            }
            n = sprintf (cc_uart_send_buffer, "%.2d  ", adcbuf[i]);
    
         	UART_write(uart,(uint8*)cc_uart_send_buffer, n);
    
        }
    
        if (peakStart != -1 && peakWidth >= minWidth)
        {
        	PeakTimeDiff[j++]=maxPeakLocation;
        }
       UART_write(uart,"\r\n", 2);
    }
    Data Array:<CR><LF>
    <NUL>172  173  175  165  181  178  176  178  176  179  181  188  190  188  188  188  181  185  183  179  189  189  186  189  182  171  182  192  193  183  189  199  199  190  194  195  191  189  189  188  193  197  196  202  194  193  195  189  199  193  192  197  192  197  198  198  198  203  197  198  193  197  194  204  189  200  197  199  200  199  201  216  214  206  205  207  206  206  200  202  206  203  203  205  203  201  201  209  206  205  211  210  207  207  207  204  205  206  208  209  207  204  209  209  208  213  200  210  206  196  205  213  223  213  213  219  212  211  226  232  238  244  244  243  243  241  243  238  239  238  250  239  248  241  242  240  242  250  246  242  236  234  233  233  236  234  235  240  237  239  238  236  243  234  237  239  242  238  241  232  247  239  229  251  232  239  244  238  247  240  239  238  238  234  232  274  241  241  241  238  250  246  231  236  237  236  237  240  238  234  237  242  235  238  242  239  242  242  234  237  241  239  239  237  240  239  233  243  241  243  242  240  226  239  236  240  238  234  237  237  234  241  243  242  241  274  245  238  241  237  239  233  232  236  236  231  250  238  245  238  239  242  236  242  240  240  238  241  241  243  <CR><LF>
    
    Data Array:<CR><LF>
    <NUL>265  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  <CR><LF>

  • I found out the problem because of stack overflow . how can i select true size of stack . after increase it to 1300 . bluetooth side dont work

  • Hello Vahid Javadi,

    When you changed the stack size did you change "#define SP_TASK_STACK_SIZE" in simple_peripheral.c? I increased the value from 644 to 1300, and was able to connect to the device using my Android S21 FE phone (using BLE Scanner, default example). It seems like your detectLongPeaks is custom code you have added to the project, did you step through the function and confirm what line causes the crash?

    Thanks,
    Alex F 

  • Hello alex , after increase stack  to 1100 code work very well but bluethooth no start  and when increase to 1200 code dont start . and when set to 960 bluethooth start but adc read one time . i have 4 event did i problem in event id ???

    #ifndef SBP_TASK_STACK_SIZE
    #define SBP_TASK_STACK_SIZE                   1100
    #endif
    // Application events
    #define SBP_STATE_CHANGE_EVT                  0x0001
    #define SBP_CHAR_CHANGE_EVT                   0x0002
    #define SBP_PAIRING_STATE_EVT                 0x0004
    #define SBP_PASSCODE_NEEDED_EVT               0x0008
    #define SBP_CONN_EVT                          0x0010
    
    // Internal Events for RTOS application
    #define SBP_ICALL_EVT                         ICALL_MSG_EVENT_ID // Event_Id_31
    #define SBP_QUEUE_EVT                         UTIL_QUEUE_EVENT_ID // Event_Id_30
    #define SBP_PERIODIC_EVT                      Event_Id_29
    #define LED_CONTROL_EVT                       Event_Id_28
    #define BLE_CONTROL_EVT                       Event_Id_27
    #define BUTTON_CONTROL_EVT                    Event_Id_26
    #define SENSOR_CONTROL_EVT                    Event_Id_25
    // Bitwise OR of all events to pend on
    #define SBP_ALL_EVENTS                        (SBP_ICALL_EVT        | \
                                                   SBP_QUEUE_EVT        | \
                                                   SBP_PERIODIC_EVT     | \
    											   LED_CONTROL_EVT      | \
    											   BLE_CONTROL_EVT      | \
    											   BUTTON_CONTROL_EVT   | \
    											   SENSOR_CONTROL_EVT)

  • Hello Vahid Javadi,

    When you mention event, which specific one are you talking about? 

    Can you provide the results/findings of your custom code and or functions, or other changes you may have made by entering in debugging mode, and placing breakpoints at your custom code or functions to confirm they are, or are not the issue? 

    I tested the ble5_simple_peripheral_cc2640r2lp_app project example provided by the SDK, changed the stack size to 1100, and 1200; in both cases I was still able see Bluetooth, and connect to the device. 

    Thanks,
    Alex F

  • I found  the problem . my sdram usage  is full because of 250 sample of adc . now i am try to reduce my usage of sdram .