[Update 8/15] Here's the file for the main part of my code: sensors.c. The sensors_start() function at the bottom is where the while loop and the print statements are located. If there are any questions about the code, please let me know.
Hello, I'm currently using the nrf51822 and I'm trying to constantly send the accelerometer data to the nRF UART v2.0 Android Application. The application is able to print the data without any problems, however when I try to constantly print the data in a while loop, it will stop printing data statements a certain number of times.
Here is a sample of what is in my while loop:
while(true)
{
if(twi_master_init())
{
acc_read_register(ACC_F_SETUP, 1, &acc_f_setup); //read FIFO Setup Register to check current FIFO buffer mode and Watermark Level
acc_read_register(ACC_INT_SOURCE, 1, &acc_int_source); //read Interrupt Status Register to check Bit 6 for FIFO Interrupt Event (Overflow or Watermark)
acc_read_register(ACC_F_STATUS, 1, &acc_status); //read FIFO Status for Buffer Overflow Info and Watermark Sample Count
modifiedRead(ACC_OUT_X_MSB, &acc_X_MSB, 18); //store data in acc_X/Y/Z_MSB and acc_X/Y/Z_LSB
acc_X_result=convert_accData(acc_X_MSB, acc_X_LSB, &acc_X_sign); //convert data to gs
acc_Y_result=convert_accData(acc_Y_MSB, acc_Y_LSB, &acc_Y_sign);
acc_Z_result=convert_accData(acc_Z_MSB, acc_Z_LSB, &acc_Z_sign);
printf("ACC X: %d", acc_X_result); //print results
printf("ACC X Sign: %d", acc_X_sign);
printf("ACC Y: %d", acc_Y_result);
printf("ACC Y Sign: %d", acc_Y_sign);
printf("ACC Z: %d", acc_Z_result);
printf("ACC Z Sign: %d\n", acc_Z_sign);
nrf_delay_ms(1250);
}
}
And the code will iterate through the loop only twice, rather than constantly, and it will print 12 statements and disconnect as seen in the screenshot below:
Some things I've tried are:
- increasing the delay with the nrf_delay_ms function
- using the ble_nus_send_string function to print instead of printf; causes the same result
- repeating the same printf statement 12+ times within the while loop, however it always stops at 12 print statements and disconnects
- flashing the onboard leds without the print statements results in the while loop to continue without any disconnections or problems
Are there any suggestions to try to get a constant flow of data to print out?
Thanks for the help,
Kenneth