Im quite new to this tool. My proj is to connect EKG board to eZ430-RF2500 target board. 1st of all, I tried to input a direct voltage to eZ430-RF2500 target board to fake as EKG signal.
I chose P2.0 (Pin 3 on the board) as input pin. Basically i juz follow the sample code “Temperature mearsure” and “Voltage measure” parts to add in code. Here is my code(simplified):
//Declaration (Only show the msg and result )
uint8_t msg[8];
int results[3];
int aNewVolt;
//Ports
P2DIR = 0x2E;
//This part is for temperature measurment (Omitted)
// I/p the voltage. I/p pin is P2.0 (pin 3, A0)
ADC10CTL1 = INCH_0; // A0
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + ADC10SR;
__delay_cycles(350); // delay to allow reference to settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(LPM0_bits + GIE); // LPM0 with interrupts enabled
results[2] = ADC10MEM;
ADC10CTL0 &= ~ENC;
//This part is for voltage measurment (Omitted)
//Passing value
aNewVolt=results[2];
msg[8]=aNewVolt;
I plug in the target board (without apply external voltage) and open the hyper terminal, the value of aNewVolt is 33 or 32.
Then i searched this forum. I saw some ppl also did similar thing as i did. I copied their code and aNewVolt value is still 32 or 33 when no input voltage is applied:
ADC10AE0 |= 0x01 ; // analog input enable for A0
ADC10CTL1 = INCH_0; // A0
ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE + ADC10SR;
__delay_cycles(350); // delay to allow reference to settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
result[2] = ADC10MEM;
ADC10CTL0 &= ~ENC;
This code is from
viewtopic.php?t=14528&highlight=ez430rf2500
I changed it slightly.
It is supposed to be 0 if i dont apply voltage, rite? Anybody plzzzz help me wiv the code???
Plus, the ground from power generator must connect to ground pin rite? Tks!!!