- Netduino Forums
- → orange's Content
orange's Content
There have been 29 items by orange (Search limited from 17-July 24)
#20987 SPI (with ADXL345)
Posted by
orange
on 26 November 2011 - 03:01 AM
in
General Discussion
#20873 SPI (with ADXL345)
Posted by
orange
on 22 November 2011 - 06:17 PM
in
General Discussion
- The second time read always gives correct Device ID now!
- The first time read returns a value which I wrote to DATA_FORMAT register last time in previous compilation (before reboot) !
While this helps passing this point, afterwards I get non-sense numbers. So issue still stands.
I'm doing exact same steps as Arduino. The only difference is that in Arduino code, we manually set Chip Select to HIGH and LOW: http://www.sparkfun.com/tutorials/240
I assumed that in Netduino case this is managed by the framework (SPI API) after each read/write. However, this may not be the case since Netduino has no idea if I'm doing two writes with the first write being register number and the second write being value unless it internally keeps a state and knows odd write are register number and even writes are values. Which kinda hints to above odd/even issue.
At this point the code is so simple that I suspect a bug in the firmware. There shouldn't be a bug in wiring as suggested before since double read always gives correct device ID.
This is Arduino code for reference:
//Parameters: // char registerAddress - The register to write a value to // char value - The value to be written to the specified register. void writeRegister(char registerAddress, char value){ //Set Chip Select pin low to signal the beginning of an SPI packet. digitalWrite(CS, LOW); //Transfer the register address over SPI. SPI.transfer(registerAddress); //Transfer the desired register value over SPI. SPI.transfer(value); //Set the Chip Select pin high to signal the end of an SPI packet. digitalWrite(CS, HIGH); }
Is there a simple way to bypass .NET framework and simply use Arduino code on Netduino? I'm spending a long time on simply a few lines of code without a way to debug in more details or a way to isolate the problem more.
#20866 SPI (with ADXL345)
Posted by
orange
on 22 November 2011 - 04:32 PM
in
General Discussion
The only hint I have is that without changing anything (code or wiring), I compile once and it fails to give Device ID (gives zero) then next time I compile it give exact correct number 0xE5. It happens after 10+ times testing. There is no lose wire that can make it exactly odd/even times correct incorrect. This is when using a Digital output for Chip Select.
Unfortunately no logic analyzer. So issue is software. I double checked with the documentation and settings are correct for idle high and falling edge. Chip Select is clearly inverted so all boolean configuration parameters are correct.
SCLK should idle high during a period of no transmission. SDI and SDO are the serial data input and output, respectively. Data is updated on the falling edge of SCLK and should be sampled on the rising edge of SCLK.
Hi orange,
Do you have a logic analyzer by any chance? That's usually how I debug these things. It's almost always an issue of SPI configuration (or wiring up the signals or power wrong). I've done it wrong a few ways
Chris
#20862 SPI (with ADXL345)
Posted by
orange
on 22 November 2011 - 04:07 PM
in
General Discussion
Would it help to upgrade firmware? How can I find out what firmware I have and an update is needed?
I tried other things e.g. changing physical wires, changing sensor, closing and re-opening the IDE, etc but the issue of Device ID still stands.
- Netduino Forums
- → orange's Content
- Privacy Policy