I'm trying to read the ACK from my uVGA-II SGC. The card is supposed to provide a 06(hex) ACK byte if successful, or a 15(hex) NAK byte if unsuccessful.
I have not been able to reliably read that byte (I sometimes get other results other than the 06 or 15), and it's clobbering my output.
This card seems really squirrelly to write to.
vgaBaud(7); //set to 14400
int vgaBaud(int z){
Serial3.print(byte(81)); //command
Serial3.print(byte(z)); //baud
if (GetResponse() == 6)
{
GetResponse();
}
}
byte GetResponse()
{
while (Serial3.available()) {
// read the incoming byte:
incomingByte = Serial3.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, HEX);
return incomingByte;
}
}
If you cleaned up your code formatting it would make it much much easier to see what's going on.
Your code snippet is incomplete so I'm making guesses as to what is going on, if you're trying to change baudrates after you've already started your connection, I don't see you changing the baudrate of your receiving hardware at all. Might it be easier to just reset the vga controller and re-autobaud at the rate that you want to end up with?
vgaBaud(7); was the call to the routine that changes the baud rate of the vga card. The uVGA-II does not support autobaud, and must be communicated with at 9600 before sending a new baud rate.