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;
results[1] = ADC10MEM; // Retrieve result
/* Stop and turn off ADC */
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;
Hi,
the highlighted code part seems to be ok (i haven't really tested it, just a quick look), but one of the most common problem if the ADC result is not correct is the sampling time. Could you test it with bigger sampling time (ADC10SHT_3 or ADC10SHT_4)? Please refer to the MSP430x2xx Family User's Guide, chapter 22.2.5.1 "Sample Timing Considerations".
Hope this helps.
-Leo-
Regards,
Leo Hendrawan
Hi Leo,
Okay. I will test it with bigger sampling time. By using the code above, I have supplied the DC supply to the board to compare the transmitted result is the same with the supply or not. The result seems to be okay. But it will stuck at 2.4V and couldn't be increase any more even my supply is 3V but it only display 2.4V in Putty. After that I tried it with square wave, I couldn't get any result from it. Do you know what's the problem ?
I think this is due to the fact that you are using the internal 2.5V reference voltage. Referring to the MSP430x2xx Family User's Guide, chapter 22.2.1 "10-Bit ADC Core", you can find the following statement:
The digital output (N ADC ) is full scale (03FFh) when the input signal is equal to or higher than V R+ , and zero when the input signal is equal to or lower than V R- .
VR+ in your code is basically the internal 2.5V input, then the maximum input is limited to this value. In this case you can try to feed an external reference output voltage to achieve conversion for input greater than 2.5V.
I hope this helps.
Thanks a lot leo. I'll test it tomorrow morning as I don't have the instrument in my house. Hopefully it works. If got any problem can I ask for your help again ?
sure, but i think you post the question on the wrong forum. Since your question is more related to the MSP430, you should post the question to the MSP430 forum instead:
http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/default.aspx
The forum is very active, and there are lot of helping hands there even from people outside TI.
Oh. Okay. I'll post it there. Sorry. I'm new here. Anyway, thanks a lot. =)