Re: Re: MMA7455L C Library and Arduino Example
Reply #7 –
I can't seem to get a + or - any value at all from the top byte register. If it is sequential (like I2C mode) then you should be able to read all 6 bytes of the 3 axis in a row, but when I do that I get the same value for the low byte of every register.
The H byte of each axis is supposed to latch in place when you read from the low, which infers to read it immediately. I have never gotten any value for the upper byte though when I read it sequentially (always 0). I think I should at least get bit 9 with +/- indication sometimes.
If I read L and H in two separate operations I still never get a value in the H byte. I think this is what your code tries to do, but it lacks the CS transition in between each read. I think your code would be correct like this instead:
MMA_PORT &= ~MMA_SS;
swspi_shift( address << 1 );
value = swspi_shift( 0 ) << 6; // low byte
---> MMA_PORT |= MMA_SS; //CS high
--->MMA_PORT &= ~MMA_SS;//CS low again
swspi_shift( ( address + 1 ) << 1 );
value |= swspi_shift( 0 ) << 14; // high byte
MMA_PORT |= MMA_SS;
return value >> 6;
I am about to work on it a little more now, I will try the 8bit mode too and post an update. I'm working on the code for the USB POV Toy with accelerometer, but I'm having a terrible time getting it going.