PASM & MMA7455 Accelerometer
bradharper
Posts: 64
I was encouraged to reference my previous post in this forum:
Anyone who has an MMA7455 available for paid consulting to get this code up and running? I'd guess it's very close to working, but just needs someone more experienced in assembly and debugging than myself to have the insight to complete it.
I'm working to piece together an assembly based MMA7455 I2C driver and I've hit a standstill. This code is a rehash of Ray's SPIN version of the driver, and an assembly version of the Basic I2C driver from OBEX.
I've structured the routines according to the MMA datasheet and in mimicry of the SPIN variant, but I've yet to get any successful sensor readings.
I've attached code that contains both the SPIN (working) and assembly (non-working) variants for anyone who has the time/motivation to glance over it for any obvious issue that may stand out. For those who actually care to run the code, just edit scl_bit, and sda_bit in the DAT section to your preferred SCL/SDA pins respectively. The SPIN interaction can be enabled by un-commenting the two lines indicated, and commenting out the cognew invocation.
For my usage, I just wanted the driver to constantly poll XYZ in 8-bit (2G) mode as fast as possible, and update three hub variables on each read. The code seems to fail on the first attempt to read from the IC, although, as best I can tell, the writes return 0-ACK as expected.
I'm inexperienced in debugging assembly, and would also appreciate any guidance, suggestions, or insights for effectively doing so.
Any insights most appreciated.
Anyone who has an MMA7455 available for paid consulting to get this code up and running? I'd guess it's very close to working, but just needs someone more experienced in assembly and debugging than myself to have the insight to complete it.
Comments
I have taken a look at your assembler code, and am running the posted program on a QuickStart board. I don't have an accelerometer, so all I can conveniently do is scope scope it, and not expect any response from the absent accelerometer.
I have some INITIAL observations:.... I have not much time to spend on this.
The two writes to each of the X, Y, Z axes seem to be of the right form, as in $1D $06 $1D $07 $1D $08 -altough not sure yet about the timiming as my board runs at 80 MHz, and your code assumes 100 MHz.
The read from each axis is non existent; as in there are no clocks for it.
I am unfamiliar with this chip, but I note that you DRIVE the SDA line high as well as low rather than PULLING the data line low and letting it FLOAT high by means of a pullup resistor. This would use the DIRA register as the source for outputting the data on a LOW pin in the OUTA register.
But perhaps this is OK for that particular chip, especially if there are no other I2C devices on that bus.
Also, the ACK timing seems a little strange, (perhaps because no chip) but I have not enough time to analyze it further today.
It's clear that in order for you to debug this circuit properly, you are going to need a scope. Please send me your co-ordinates, and I'll send you one tomorrow (a 4 channel CRT type).
If you would like me to investigate further, please send me an accelerometer chip.
Cheers,
Peter (pjv)