I am using the LPC2148-based MP3 board to create some simple games that use the accelerometer for control. Things were working fine when I was just looking at the X and Y axes, but when I decided to use the Z axis I found that calls to MMA_get_z only return 0 (actually, sometimes it returns the occasional 1.) For reference, the X and Y return values are roughly in the 200 to 800 range.
I’ve looked over the included code, and it looks like the A/D is initiallized for all three chanels; and I’ve looked at the schematic and board and it looks like all three channels are wired up and that the resistors and caps for the Z channel are populated. Has anyone else tried to use the Z channel and found that it’s not working? Maybe I have a bad accelerometer or a bad solder joint.
If I take the sample MP3 player code, and insert the following code at line 102 of main.c (immediately after the sparkfun logo is displayed)
VICIntEnClr = 0x10; //Disable interrupts before querying accelerometer
delay_ms(250);
for(int j=0; j<30; j++){
LCDClear(white);
switch(j%3){
case 0:
LCDPrintString("X: %d", MMA_get_x(), black, 2, 1, 0);
break;
case 1:
LCDPrintString("Y: %d", MMA_get_y(), black, 2, 1, 0);
break;
case 2:
default:
LCDPrintString("Z: %d", MMA_get_z(), black, 2, 1, 0);
break;
}
delay_ms(1250);
}
VICIntEnable |= 0x10; //Re-enable interrupts
then the screen will alternately display “X: ~500; Y: ~500; Z: 0” Could anyone insert this code into the default main.c and see if it produces something different on their system?
Many thanks,