Have you already checked the examples in the IDE? Take a look at the Shield Tests Report you could find some examples, codes, shields and results.
Let me know if this helps or if you already have tried this.
I did take a look at that, I was sort of confused about the swizzler pins.. Out of the box do I need to change anything to use the SPI functionality?
Works for me. I have done some stuff with the Adafruit 2.8" tft display which uses SPI. I have done it using the IO pins 11-13 (actually 10 as well for CS ...)
Swizzler are only for PWM and are only to be used if you have an issue with the physical location of the PWM pins. SPI should work out of the box.
The problem is not resolved. I use the same code on my Arduino Uno, same pins and everything works like a charm. However, once i run the code on the edison, it just doesnt work.
Need more info, like what display, what code base, what does not work...
Its an ADC. Specifically the PmodAD5 from digilent. I'm using their supplied arduino drivers from here:
There is code on that page for arduino. I have run it successfully on my UNO. The code initializes the registers on the adc. The problem is that it fails initialization on the edison for some reason.
Out of curiosity I took a quick look through. From what I saw, the main file, works through a secondary file (communication.c (.h)) for a few functions (SPI_Init, SPI_Read, SPI_Write), which look like they are hardware dependent on the Arduino. That is they are talking directly to the hardware registers, instead of using something like the SPI library. It probably would not be too hard to convert the file to use the spi library. Alternatively someone could try to do some similar c++ hacks like Paul of PJRC did for the Teensy and setup c++ classes with operator overloads and the like such that doing stuff to the SPI registers is converted into appropriate calls to SPI...
I made a mistake and sent you the wrong link. Someone already made the drivers to run purely on the SPI arduino library (link)
and it works on the UNO. ADConverter
So not sure why it does not want to function properly.
1 of 1 people found this helpful
Yes, that makes a little more sense.
Sorry I don't have the time to dig here. But I am wondering some about how that sketch handles the MOSI pin as well as the CS pin.
It might not be necessary, but In the case of the CS pin, I would probably add a pinMode(SS, OUTPUT); probably in the init() function.
As for MOSI pin - It uses that define in:
#define AD7193_RDY_STATE MOSI //define pin MOSI( MISO is automaticaly defined)
It then has function that is checking for this state to go low...
But the MOSI pin will be in a different MUX mode so I don't think that will work.
I am not sure if it is trying to stretch out the time? Not sure... Might comment comment it out and see if it helps... Or may have to see if other method to see when device is ready, having to switch pin mode do read, switch pin mode back...
Awesome! That was it. adding "pinMode(SS, OUTPUT); " after initializing the SPI library got it going! Ugh so happy now.
Out of intellectual curiosity. Why did I need to do that?
Because by default IO pins default to be input pins. Maybe the Arduino did this as a side effect in their SPI library. I just usually make sure by setting pins to the state I want and not rely on hopefully something else did so...
Glad it is now working for you