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.
Hi guys. I'm required to transmit the data from the function generator by connecting the output of the function generator directly to the MSP430 eZ430-RF2500 board and transmit the data to PC. I couldn't get the data. Can anyone help me on it ? Below are my code. Can anyone tell me where i've write it wrongly ? Thanks...
/* Time to measure */
if (sSelfMeasureSem) {
volatile long temp;
int degC, TransmittedData,value;
int results[2];
#ifdef APP_AUTO_ACK
uint8_t noAck;
smplStatus_t rc;
#endif
/* Get temperature */
ADC10CTL1 = INCH_10 + ADC10DIV_4; // Temp Sensor ADC10CLK/5
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + ADC10SR;
/* Allow ref voltage to settle for at least 30us (30us * 8MHz = 240 cycles)
* See SLAS504D for settling time spec
*/
__delay_cycles(240);
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
results[0] = ADC10MEM; // Retrieve result
ADC10CTL0 &= ~ENC;
/* Get TransmittedData */
ADC10AE0 |= 0x02;
ADC10CTL1 = INCH_4 + ADC10DIV_4; // waveform Sensor ADC10CLK/5
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;
__delay_cycles(240);
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
results[1] = ADC10MEM; // Retrieve result
ADC10CTL0 &= ~ENC;
/* Stop and turn off ADC */
ADC10CTL0 &= ~ENC;
ADC10CTL0 &= ~(REFON + ADC10ON);
/* oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278
* the temperature is transmitted as an integer where 32.1 = 321
* hence 4230 instead of 423
*/
temp = results[0];
degC = ((temp - 673) * 4230) / 1024;
if( (*tempOffset) != 0xFFFF )
{
degC += (*tempOffset);
}
/* message format, UB = upper Byte, LB = lower Byte
-------------------------------
|degC LB | degC UB | volt LB |
-------------------------------
0 1 2
*/
TransmittedData = results[1];
value = TransmittedData*0.024;
msg[0] = degC&0xFF;
msg[1] = (degC>>8)&0xFF;
msg[2] = value;
**Attention** This is a public forum