This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ADC + ble connection

I am using nrf51_sdk_v6_0_0_43681 and s110_nrf51822_7.0.01 wiht nrf51822, and I modifiy code based on ble_app_uart.

Here I am trying to launch a continous ADC sample with a repeated mode timer, the timer interval is 1ms or 2ms or 4ms. Meanwhile I disconnect and conect my cellphone(Samsumg Notes 3) with nrf51822 board. Serval times later, I found that the nrf51822 system should be crashed,because my local uart can not be input and ble has no advertising.

What is the problem?

Thanks

Frank

Edit: Format + Added commas between tags

Parents
  • Hi Stefan, Great thanks for your answer.Here I found that continously ADC sampling is not the root cause of system crash. I have an function xxx_process in main loop runtine as below. It is a complicated algorithm, sometimes it will take about 2 second to finish it. When algorithm is running, and I connect/disconnect the board with my cellphone, it will cause system crash. Here I want to know if I can disable ble response before algorithm running and enable ble response after algorithm finish.

    main() { ..... //initialization for (;;) { xxx_process(); power_manage();

    }
    

    }

    Thanks Frank

Reply
  • Hi Stefan, Great thanks for your answer.Here I found that continously ADC sampling is not the root cause of system crash. I have an function xxx_process in main loop runtine as below. It is a complicated algorithm, sometimes it will take about 2 second to finish it. When algorithm is running, and I connect/disconnect the board with my cellphone, it will cause system crash. Here I want to know if I can disable ble response before algorithm running and enable ble response after algorithm finish.

    main() { ..... //initialization for (;;) { xxx_process(); power_manage();

    }
    

    }

    Thanks Frank

Children
  • You could disconnect before the algorithm executes, then advertise when it finishes in order to connect again. You can also set the slave latency to a relatively high number so that the nRF51 device is not required to respond to the phone for a number of connection events. What I am curious to know however, why is the device crashing when you press connect/disconnect. The code that you execute in the main function has lowest priority and should not interrupt any softdevice activity.

  • Hi Stefan, I think that I have found the key problem. Nrf51822 has problem with process dyadic array. Please see xxx_process() as below, it is just a test case. If I enable dyadic array, the system will crash when connecting/disconnecting, if I disable dyadic array, it should be OK. I think that it should be a bug. Please check and confirm it. void xxx_process(void) { long N,M; long i,j,s,r,t; float temp; long k1,k2; float u,v,w; float Re[256]; float Am[256]; float Im[256][256]; float pi = 3.1416;

    for(i=0;i<256;i++) { for(j=0;j<256;j++) { Re[i]=i; Am[i]=i; //Im[i][j]=j; } }

    for(i = 0; i<256;i++) { for(j = 0; j<20000;j++) { u = Re[i]cos(2jpi/256)+ Am[i]sin(2jpi/256); v = Re[i]cos(2jpi/256)- Am[i]sin(2jpi/256);

    	 //w = sqrt(u*u+v*v);
    	 w = sqrt(u*u+v*v)+Im[i][j];
    }
    

    }

    } main() { ..... //initialization for (;;) { xxx_process(); nrf_delay_ms(5); power_manage();

    } }

  • What math library do you use for the cos/sin functions? What is your connection parameters, i.e. connection interval, slave latency and timeout?

  • Hi Stefan, I just include math.h, sin/cos/sqrt can be available. Below is my connection parameters: #define MIN_CONN_INTERVAL 24 #define MAX_CONN_INTERVAL 90 #define SLAVE_LATENCY 0 #define CONN_SUP_TIMEOUT 400 #define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER) #define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(30000, APP_TIMER_PRESCALER) #define MAX_CONN_PARAMS_UPDATE_COUNT 3 #define APP_ADV_INTERVAL 128 #define APP_ADV_TIMEOUT_IN_SECONDS 0

Related