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

Nordic UART Service send a 10 bit value over BLE?

Hi,

I programmed the NRF51-dk to take ADC samples and transmit those values at 8 bit resolution. Now I want to send a 10 bit resolution value over BLE UART, but I believe the limit for the ble_nus_string_send function only sends up to 8 bits. Right now I store the 10 bit ADC value as an uint16_t. I thought about dividing the 16 bit into two 8 bit unsigned integers and then sending them separately, but I wanted to know if it was possible to send up to 16 or at least 10 bits. My code:

void ADC_IRQHandler(void)
{
//	uint16_t adc_result_calibrated;
	uint16_t adc_result;
	
	/* Clear dataready event */
  NRF_ADC->EVENTS_END = 0;	
	
	adc_result = NRF_ADC->RESULT;	
	uint8_t adc_low = adc_result & 0xff;
	uint8_t adc_high = (adc_result >> 8);
	app_trace_log("Value: %X%X\r\n",adc_high,adc_low);   //log ADC reult on UART
	ble_nus_string_send(&m_nus, &adc_result , 1);
	
	//Release the external crystal
	sd_clock_hfclk_release();
}	
Related