Hi all, I am having some trouble using SPI, I am using a raspberry pi pico but I am using the arduino IDE to do all the software. Pretty much I am making a function generator using AD9834, below is my code, I dont think I am getting any SPI communication, as I can't see anything on my scope, ik a logic analyser would be better but I don't have one.
I havent used SPI a lot, so is there anything obvious that I have done wrong in the code, I followed a youtube video as a guide. Only thing im not sure is that in the video he declares the TX pin (SDATA for AD9834) but then never uses it, isn't the TX pin the one that sends the data?
code shown here:
#include <SPI.h>
const int On_Board_LED = 25;
const int RST = 0;
const int FSYNC1 = 5;
void setup() {
// put your setup code here, to run once:
pinMode(On_Board_LED, OUTPUT);
pinMode(RST, OUTPUT);
pinMode(FSYNC1, OUTPUT);
digitalWrite(On_Board_LED, LOW);
digitalWrite(RST, HIGH);
digitalWrite(FSYNC1, HIGH);
SPI.begin();
SPI.beginTransaction(SPISettings(5000000, MSBFIRST, SPI_MODE0));
AD_RESET();
AD_FREQ();
AD_ENABLE();
delay(500);
digitalWrite(RST, LOW);
}
void AD_RESET(){
digitalWrite(FSYNC1, LOW);
SPI.transfer(0x21);
SPI.transfer(0x00);
digitalWrite(FSYNC1, HIGH);
}
void AD_FREQ(){
digitalWrite(FSYNC1, LOW);
//These 4 SPI trasfer lines are for setting the frequency
//Refer to the Data sheet for how this is done
SPI.transfer(0x7F);
SPI.transfer(0x7C);
SPI.transfer(0x7B);
SPI.transfer(0x60);
//This is setting the phase of the signal to 0 phase adjustment
SPI.transfer(0x00);
SPI.transfer(0x00);
digitalWrite(FSYNC1, HIGH);
}
void AD_ENABLE(){
digitalWrite(FSYNC1, LOW);
SPI.transfer(0x22);
SPI.transfer(0x00);
digitalWrite(FSYNC1, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(On_Board_LED, HIGH);
}
Anyway any help with this would be greatly appreciated.
Thanks in advance Dean.