Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use BitOrder instead of uint8_t on SAMD chips #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wrong-kendall
Copy link

@wrong-kendall wrong-kendall commented Jan 14, 2021

The library doesn't appear to compile using platformIO and a feather express m4 because the SPI library uses BitOrder instead of uint8_t.

@evermore99
Copy link

evermore99 commented Jan 14, 2021

The library doesn't appear to compile using platformIO and a feather express m4 because the SPI library does uses BitOrder instead of uint8_t.

I tried running the full program from the evaluation board cn0391. This works on an arduino uno. however this does not work on a teensy4.1 with arduino 1.8.7. I can give you the source code... I also use on the same bus a featherwing 3.5inch. I did recordings with my scope and somehow the MISO isn’t sending back

@wrong-kendall
Copy link
Author

Huh. So just to be clear, with this change patched in, the sketches work for the arduino uno (unaffected by my change because I think it is an ATmega328P) but doesn't work with teensy (should be affected if they define SAMD_SERIES, which I think they do)? Without this change, does compilation for the teensy fail? I don't have a teensy but I'll try again with my m4 express and verify that I didn't overlook something.

@BastiaanMDC
Copy link

BastiaanMDC commented Jan 14, 2021 via email

@wrong-kendall wrong-kendall changed the title Use BitOrder instead of unit8_t on SAMD chips Use BitOrder instead of uint8_t on SAMD chips Jan 15, 2021
@wrong-kendall
Copy link
Author

wrong-kendall commented Jan 15, 2021

I just saw #12, which is a report of the same thing. In that issue, BastiaanMDC mentions that he has it working on a teensy3.6, which should be a SAMD. I wonder if teensy has its own SPI implementation. I know that the m4 referenced the one used by the Zero. If teensy worked before and doesn't with this change, then SAMD_SERIES is probably incorrect. If someone can confirm that I'll start trying to track that down.

@BastiaanMDC, replying to your last question, I wouldn't have thought that the SAMD chips would not be fundamentally different (aside from possibly using different SPI libraries).

@wrong-kendall
Copy link
Author

Okay, I just verified that my proposed change using an adafruit m4 express (SAMD51) and a simple feather wing that I made for the AD7124 does work. Here is the simple program I used to test. The feather wing is just 4 voltage dividers (each 3V/2) connected to AIN{0,2,4,6} with the other AINs connected to GND, the AD7124 and the necessary capacitors.

After doing a verbose build with PlatformIO, it's pulling in framework-arduino-samd-adafruit 1.6.4, which includes this SPI.h. Tomorrow, I'll try with the Arduino IDE and see if my change still works with the m4 there. And then I'll see what I can determine about the teensy, without actually having one...

That being said, I'm still very perplexed by #14 (comment) because I would not have expected it to compile and then silently fail.

@BastiaanMDC
Copy link

Okay, I just verified that my proposed change using an adafruit m4 express (SAMD51) and a simple feather wing that I made for the AD7124 does work. Here is the simple program I used to test. The feather wing is just 4 voltage dividers (each 3V/2) connected to AIN{0,2,4,6} with the other AINs connected to GND, the AD7124 and the necessary capacitors.

After doing a verbose build with PlatformIO, it's pulling in framework-arduino-samd-adafruit 1.6.4, which includes this SPI.h. Tomorrow, I'll try with the Arduino IDE and see if my change still works with the m4 there. And then I'll see what I can determine about the teensy, without actually having one...

That being said, I'm still very perplexed by #14 (comment) because I would not have expected it to compile and then silently fail.

really thanks for looking into this.

its a wonderful chip.

@wrong-kendall
Copy link
Author

I just confirmed that my changes with my test sketch in the Arduino IDE (1.8.13) running on the m4 express still works. Next up, I'll try to figure out if my change breaks the teensy.

@evermore99 were you testing with https://wiki.analog.com/resources/eval/user-guides/eval-adicup360/hardware/cn0391?doc=CN0391.pdf? I figured I should get a similar setup so we are comparing the same thing.

@BastiaanMDC
Copy link

BastiaanMDC commented Jan 16, 2021 via email

@wrong-kendall
Copy link
Author

I've got a teensy and a cn0391 on the way so we'll be able to compare similar setups. I'll update this once they arrive and I've had a chance to experiment with them.

@BastiaanMDC multiple SPI devices on the same bus should be as trivial as using a different {Chip,Slave}Select pin on your microcontroller. When you initialize each on using a different pin, the SPI library should transparently handle the multiple devices for you by holding the SS/CS line low for the device you want to communicate with. Here is a tutorial

@BastiaanMDC
Copy link

BastiaanMDC commented Jan 19, 2021 via email

@wrong-kendall
Copy link
Author

Okay. Sorry for the delay. I've finally gotten a cn0391, and more importantly, time to debug. I hooked up the cn0391 arduino shield to an Uno compatible board and was able to use the example provided by analog devices. That test worked fine.

Now to test with this library, which example should I use with the cn0391? @evermore99 and @BastiaanMDC, you both mention testing the cn0391 with this library; are you using the Full Test or something else? I just want to make sure I'm replicating your tests as best as possible. Thanks!

P.s. @BastiaanMDC, I haven't forgotten about your multi device SPI problem, I just want to get to the point where we're testing the same things before I delve into that.

@evermore99
Copy link

evermore99 commented Feb 18, 2021 via email

@BastiaanMDC
Copy link

BastiaanMDC commented Feb 19, 2021 via email

@evermore99
Copy link

evermore99 commented Feb 22, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants