Need help with eZ430-RF2500...

Hey everyone! Need some urgent help… First I’ll say I’m a software developer, and the embedded stuff is new to me, so please go gently on me. :slight_smile:

I have an ADXL330 accelerometer connected to the board like so:

[

To be more clear:

P1 <-> GND
P2 <-> VDD
P3 <-> X (analog input A0)
P4 <-> Y (analog input A1)
P5 <-> Z (analog input A2)

I’m trying to read data from the analog inputs. This is my function:

void getData(int* x, int* y, int* z)
{
  int degC;

  ADC10AE0 |= 0x01 ;  // analog input enable for A0
  ADC10CTL1 = INCH_0;                  // A0
  ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE + ADC10SR;
  for( degC = 240; degC > 0; degC-- );  // delay to allow reference to settle
  ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start
  __bis_SR_register(CPUOFF + GIE);      // LPM0 with interrupts enabled
  *x = ADC10MEM;
  ADC10CTL0 &= ~ENC;
  ADC10CTL0 &= ~(REFON + ADC10ON);      // turn off A/D to save power
 
  ADC10AE0 |= 0x04 ;  // analog input enable for A1
  ADC10CTL1 = INCH_1;                  // A1
  ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE + ADC10SR;
  for( degC = 240; degC > 0; degC-- );  // delay to allow reference to settle
  ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start
  __bis_SR_register(CPUOFF + GIE);      // LPM0 with interrupts enabled
  *y = ADC10MEM;
  ADC10CTL0 &= ~ENC;
  ADC10CTL0 &= ~(REFON + ADC10ON);      // turn off A/D to save power
 
  ADC10AE0 |= 0x08 ;  // analog input enable for A2
  ADC10CTL1 = INCH_2;                  // A2
  ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE + ADC10SR;
  for( degC = 240; degC > 0; degC-- );  // delay to allow reference to settle
  ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start
  __bis_SR_register(CPUOFF + GIE);      // LPM0 with interrupts enabled
  *z = ADC10MEM;
  ADC10CTL0 &= ~ENC;
  ADC10CTL0 &= ~(REFON + ADC10ON);      // turn off A/D to save power
}

It is based on the temperature sensor example from TI. For some reason, I do not get correct data… :frowning: Anyone could shed some light on the problem?

Thanks in advance,

Leo Natan](ImageShack - Best place for all of your image hosting and image sharing needs)

Hey, if you get this to work please let me know how you implemented it in code, i’m trying to do exactly what you are doing and I wanna know if you had any success…i’m surprised I stumbled upon someone else that’s trying to attach an accelerometer to the pins.

The one i’m using is the ADXL320 +/- 5 g.

I was thinking about doing that same thing and modify the code…but I don’t understand why are you are using all the Celsius temperature junk …i mean isn’t the accelerometer different than the temperature sensors on board the target board and application device??

I just wanna know how you code it…have you gotten any replies? TI instruments sucks big time… I tried to call customer support and they practically ignored my request…

what’s the point of buying their hardware if they example demo they give is so application specific…that’s it nearly impossible to understand how to write your own programs? anywho…let me know if you ever figured this out…I really need to know how to get this to work for one of my projects…ASAP…if you want shoot me your e-mail.

Try the TI forums.

Leon

you are probably getting stuck in low power mode.

make sure to service the interrupt that the ADC will produce when it is done with the conversion process. In the interrupt you must exit from low power mode so the CPU is alive again and can return from the ISR and continue to execute code in main. The easiest way to do this is to not go into low power mode in the first place and to just poll the ADC interrupt flag in your normal code execution. If you want to save battery, then the low power mode feature should be used.

This is where you kill your CPU and wait for the interrupt…

__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled

if you can’t step past this statement in your code, your CPU is turned off and will not turn back on until you tell it to in an ISR.