4D uVGA-II SGC Issues

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;
}
}

Steve Spence

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.

I did resolve the issue, however.

I built the following routine:

// check ack / nack
byte nacAck() {
  byte b=0x00; // 0x06;
  while (!(Serial3.available())) {     
    delay(2);   
  }
  b = Serial3.read();
  return b;
}

and place a call at the end of each command sequence:

      //opaque text

  Serial3.print("O");

  Serial3.print(byte(01));

  a = nacAck();

Yes, that's the code I sent you...

There were a couple of sticky issues converting my code to Arduino 1.0. Here are the areas that I found:

Serial3.print(byte(00)); //terminator
becomes
Serial3.write((uint8_t)0); //terminator

Serial3.print(byte(y)); //color
becomes
Serial3.write(y); //color

and

Serial3.print(int(z)); //data
stays the same