Quantcast
Channel: Wireless Connectivity
Viewing all articles
Browse latest Browse all 116964

Forum Post: ADC to radio

$
0
0
Hi,
I am trying to write a code to ADC a continuous sine wave (pin 7 input) and transmit it to a receiver by SimpliciTI. I am still learning, so please help!
After establishing the link between the two end devices, I try to do an endless loop ( ADC conversion -- SMPL_Send ).  The following is the code, no DMA is needed, and it seems quite simple, will it work?  Many thanks!

// Set pin7 as ADC input
ADCCFG |= ADCCFG_7;

while (1)
{

// Start ADC conversion on pin7
ADCCON3 = ADCCON3_EREF_AVDD | ADCCON3_EDIV_256 | ADCCON3_ECH_AIN7;


// Wait for ADC conversion to complete
while( !(ADCCON1 & ADCCON1_EOC));

// Store the ADC result from the ADCH/L register to the radioMsg variable
radioMsg = ADCL & 0xC0;
radioMsg |= (ADCH << 8);

// Send the radioMsg
SMPL_Send(sLinkID, radioMsg, sizeof(radioMsg));

}


Viewing all articles
Browse latest Browse all 116964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>