I have a breakout board for AD9835 by sparkfun. I am trying to interface it with a Raspberry Pi. Since the chip has 5V SPI, I am using a level shifter. All other pins work fine, but when i connect the MOSI pin of RPi to the input of level shifter, it inverts the MOSI logic. Gives HIGH on a 0 and LOW on a 1. Why is this happening?
To solve this I connect the MOSI pin directly to the ad9835 SDATA pin, no matter whatever frequency word i send(32 bit word), the frequency is stuck on 5MHz. Is it because MOSI level is 3.3v and its not getting detected?
You might ask this question on a Raspberry Pi forum or mailing list. There may be some esoteric behavior of the SPI port on the Pi that we Arduino users are less likely to know about.
I have been stuck on this problem for more than a week now! The library i use makes arduino codes compatible on raspberry pi. I have no idea why the MOSI pin is behaving this way!
To solve this I connect the MOSI pin directly to the ad9835 SDATA pin, no matter whatever frequency word i send(32 bit word), the frequency is stuck on 5MHz.
so obvious this is not the solution.
The source you provided does compile (after an #include and creating a global int for slaveselect) on my 1.0 but as I have no ad9835 I connet test it further.
Do you have the link to the datasheet you used? of the ad9835 ?
There might be a bug in the arduPi library which does "flip" the MOSI ?
Have you got other SPI based sketches running properly?
The source you provided does compile (after an #include and creating a global int for slaveselect) on my 1.0 but as I have no ad9835 I connet test it further.
The source code i uploaded was is the arduino code. for raspberry pi i removed the # define SlaveSelectPin, actually it does not make a difference because the slaveselect pin is fixed on the pi.
Even I thought the ardupi may have some bugs. but i tested it for other basic SPI, and SPI works fine!
I have used a npn transistor as inverter to get the original MOSI signal back and the signal now is correct. Now i am getting correct signals of MOSI,SCLK,SS. So basically all signals are as required, but still no ouput. I am guessing the problem might be with the frequency of SPI. will try all permutations and combinations. Hope it works. Will update,