weird_dave:
What are you using to measure the voltages on the IO pins?
What are the part numbers of the devices you're using, datasheets are the proper way to check.
An Agilent 34461a.
Well I can't seem to find a data sheet for the breakout board but it's made by Adafruit:
and the SD card:
The camera is a "PTC08" according to the data sheet also courtesy of Adafruit:
weird_dave:
The coax stopped the clock spewing RF all over the place, it was causing corruption on the data lines, but my wires/cables were a bit longer (I now have a PCB made with appropriate shielding of the SPI lines).
There might be a fault with the code, it may be worth pasting it here.
Okay that makes sense, my clock line is about 3 inches or so but at least works with other SPI programs.
Sure I'm not sure how much I should paste here because it's all contained in the github link in my original post but here's some of the important bits/lines I changed.
This is the main code that had only some minor changes to initialize hardware serial (just involved commenting out 3 lines regarding software serial and uncommenting the hardware serial option):
//#include "SoftwareSerial.h"
#include <VC0706_UART.h>
#include <SD.h>
#include <SPI.h>
#define SS_SD 10
//use software serial
//SoftwareSerial cameraconnection(2,3);//Rx, Tx
//VC0706 cam = VC0706(&cameraconnection);
//use hardware serial
VC0706 cam = VC0706(&Serial1);
void setup()
{
Serial.begin(9600);
Serial.println("VC0706 Camera Snapshot Test ...");
if (!SD.begin(SS_SD)) {
Serial.println("SD Card init failed...");
return;
}
if(true == cameraInit()){
snapShot();
}else{
Serial.println("camera init error...");
}
}
void loop()
{
//nothing to do
}
bool cameraInit()
{
cam.begin(BaudRate_19200);
char *reply = cam.getVersion();
if (reply == 0) {
Serial.println("Failed to get version");
return false;
} else {
Serial.println("version:");
Serial.println("-----------------");
Serial.println(reply);
Serial.println("-----------------");
return true;
}
}
void snapShot()
{
Serial.println("Snap in 3 secs...");
delay(3000);
if (! cam.takePicture()){
Serial.println("Failed to snap!");
}else {
Serial.println("Picture taken!");
}
// Create an image with the name IMAGExx.JPG
char filename[13];
strcpy(filename, "IMAGE00.JPG");
for (int i = 0; i < 100; i++) {
filename[5] = '0' + i/10;
filename[6] = '0' + i%10;
// create if does not exist, do not open existing, write, sync after write
if (! SD.exists(filename)) {
break;
}
}
// Open the file for writing
File imgFile = SD.open(filename, FILE_WRITE);
Serial.print("create ");
Serial.println(filename);
uint16_t jpglen = cam.getFrameLength();
Serial.print("wait to fetch ");
Serial.print(jpglen, DEC);
Serial.println(" byte image ...");
int32_t time = millis();
cam.getPicture(jpglen);
uint8_t *buffer;
while(jpglen != 0){
uint8_t bytesToRead = min(32, jpglen);
buffer = cam.readPicture(bytesToRead);
imgFile.write(buffer, bytesToRead);
//Serial.print("Read "); Serial.print(bytesToRead, DEC); Serial.println(" bytes");
jpglen -= bytesToRead;
}
imgFile.close();
time = millis() - time;
Serial.println("Done!");
Serial.print("Took "); Serial.print(time); Serial.println(" ms");
cam.resumeVideo();
}
The actual SPI protocols aren't in the main file but in the library's cpp file, here's a snippet of where things may be acting up. I've tried different setting for the clock divider and data mode without luck. I also manually swapped SLAVE_PIN with pin 10 because it almost seems like SLAVE_PIN is set in the header file to pin 8 yet is set to pin 10 in the main file and isn't changed. I almost thought I had solved the problem but that didn't change anything either.
#if TRANSFER_BY_SPI
pinMode(SLAVE_PIN, OUTPUT);
digitalWrite(SLAVE_PIN,HIGH);
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV4);
SPI.setDataMode(SPI_MODE0);
SPI.begin();
#endif
And in the header file the only changes were commenting out SoftwareSerial.h and setting USE_SOFTWARE_SERIAL to 0.