Hey everyone,
I am currently stuck at a point where I don't see any light
I am trying to connect EZ430-RF2500 to a voltage and current sensor at ports: P3 (Pin 2.0) as Voltage and P4 (Pin 2.1) as Current.
This is a snippet of my code for my TRANSMITTER/END DEVICE below:
*******************************************************************************************************
static void linkTo()
{
uint8_t msg[5];
#ifdef APP_AUTO_ACK
uint8_t misses, done;
#endif
/* Keep trying to link... */
while (SMPL_SUCCESS != SMPL_Link(&sLinkID1))
{
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();
/* Go to sleep (LPM3 with interrupts enabled)
* Timer A0 interrupt will wake CPU up every second to retry linking
*/
__bis_SR_register(LPM3_bits+GIE);
}
/* Turn off LEDs. */
BSP_TURN_OFF_LED1();
BSP_TURN_OFF_LED2();
/* Put the radio to sleep */
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0);
while (1)
{
/* Go to sleep, waiting for interrupt every second to acquire data */
__bis_SR_register(LPM3_bits);
/* Time to measure */
if (sSelfMeasureSem) {
volatile long temp;
int degC, volt;
int load_Voltage = 0;
int load_Current = 0;
int results[4];
#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 voltage */
ADC10CTL1 = INCH_11; // AVcc/2
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
/************************ Get Load_Voltage *******************************/
ADC10CTL1 = INCH_0; // A0 - P3
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[2] = ADC10MEM; // Retrieve result
/************************ Get Load Current *******************************/
ADC10CTL1 = INCH_1; // A1 - P4
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[3] = ADC10MEM; // Retrieve result
/* 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 | volt Load | current Load |
------------------------------------------------------------------------------
0 1 2 3 4
*/
temp = results[1];
volt = (temp*25)/512;
temp = results[2];
load_Voltage = temp;
load_Current = results[3];
msg[0] = degC&0xFF;
msg[1] = (degC>>8)&0xFF;
msg[2] = volt;
msg[3] = load_Voltage;
msg[4] = load_Current;
BSP_TOGGLE_LED1();
*******************************************************************************************************
This was a demo code (EZ430-RF2500 Wireless Sensor Monitor) that I downloaded from TI website and modified it to do my bidding, the code that I added is:
/************************ Get Load_Voltage *******************************/
ADC10CTL1 = INCH_0; // A0 - P3
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[2] = ADC10MEM; // Retrieve result
/************************ Get Load Current *******************************/
ADC10CTL1 = INCH_1; // A1 - P4
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[3] = ADC10MEM; // Retrieve result
I also modified the msg[ ] and results[ ] array but that is just minor stuff and I believe I did an okay job on them. It's just this part, I am quite doubtful about. How do I declare P2.0 and P2.1 as Inputs? Maybe that is what I am missing here?
I don't seem to be getting any values out in my Putty Window... any suggestions? Guys, I would really appreciate your help in this.