Beat Bearing Code Error

I am getting the following error

Binary sketch size: 3124 bytes (of a 14336 byte maximum)

avrdude: stk500_loadaddr(): (a) protocol error, expect=0x14, resp=0xfe

avrdude: stk500_paged_load(): (a) protocol error, expect=0x14, resp=0xe6
avrdude: stk500_cmd(): programmer is out of sync

I can load and run the Blink LED sketch just fine. The code compiles fine. Is this just not running because I don’t have things all hooked up yet and the board is expecting to read some values from multiplexer chips? http://www.make-digital.com/make/vol17/?pg=128 Here’s the project Anyone see any other issues? Here’s the code

/*

  • Beatbearing firmware
  • Peter Bennett
  • pete@petecube.com
  • NOTE:
  • this isn’t the most efficiently coded program, but is the one that I was using as a prototype
  • when writing up the BeatBearing article
  • Keep an eye on www.beatbearing.co.uk for suggested updates to this firware,
  • including a version with proper debouncing and use of the digital pins for input.
  • Make sure to choose correct board and serial port before programming
  • This was written in Arduino v12
    */

int A0_1 = 2; // declare output pins
int A1_1 = 3;
int A2_1 = 4;
int A3_1 = 5;
int A0_2 = 6;
int A1_2 = 7;
int A2_2 = 8;
int A3_2 = 9;

int Z_1 = 0; // declare input pins
int Z_2 = 1;

int thresholdLow = 3000;
int thresholdHigh = 7000;

int stateMatrix[32][8] = { // stores all of the values.
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0};

int averages[32] = { // stores all of the values.
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0};

boolean bState[32] = {
B0, B0, B0, B0, B0, B0, B0, B0,
B0, B0, B0, B0, B0, B0, B0, B0,
B0, B0, B0, B0, B0, B0, B0, B0,
B0, B0, B0, B0, B0, B0, B0, B0};

void setup() {

Serial.begin(9600);

pinMode(A0_1, OUTPUT); // set outputs
pinMode(A1_1, OUTPUT);
pinMode(A2_1, OUTPUT);
pinMode(A3_1, OUTPUT);

pinMode(A0_2, OUTPUT);
pinMode(A1_2, OUTPUT);
pinMode(A2_2, OUTPUT);
pinMode(A3_2, OUTPUT);
}

void loop(){

byte byteOut1 = B00000000;
byte byteOut2 = B00000000;
byte byteOut3 = B00000000;
byte byteOut4 = B00000000;
byte byteOut5 = B00000000;
byte stopByte = B11111111;

for (int a = 0; a < 32; a++) { // first shift all old values up
for (int b = 7; b > 0; b–) {
stateMatrix[a] = stateMatrix[a][b-1];
** }**
** }**
** for (long count = 0; count < 16; count++) { // now get all the states 0-1024**
** digitalWrite(A0_1, (count >> 3) & 1);**
** digitalWrite(A1_1, (count >> 2) & 1);**
** digitalWrite(A2_1, (count >> 1) & 1);**
** digitalWrite(A3_1, (count >> 0) & 1);**
** digitalWrite(A0_2, (count >> 3) & 1);**
** digitalWrite(A1_2, (count >> 2) & 1);**
** digitalWrite(A2_2, (count >> 1) & 1);**
** digitalWrite(A3_2, (count >> 0) & 1);**
** stateMatrix[count][0] = analogRead(Z_1); // and insert new values at position 0**
** stateMatrix[count + 16][0] = analogRead(Z_2);**
** }**
** for (int a = 0; a < 32; a++) { // now calculate averages**
** averages[a] = 0;**
** for (int b = 0; b < 8; b++) {**
__ averages[a] += stateMatrix[a];__
** }**
** }**
** // determine binary state using thresholds**
** for (int n = 0; n < 32; n++) {**
** if ((bState[n] == B0) && (averages[n] < (thresholdLow))) { // last sure value was 0 AND below low threshold**
** bState[n] = B1; // then set to 1;**
** }**
** else if ((bState[n] == B1) && (averages[n] > (thresholdHigh))){ // last sure value was 1 AND over high threshold**
** bState[n] = B0; // set to 0;**
** }**
** }**
** // now assemble the output bytes**
** int stateCount = 0;**
** // first byte**
** for (int n = 0; n < 7; n++) {**
** if (bState[stateCount] == B1) {**
** byteOut1 |= (1 << n); // then set to 1;**
** }**
** else {**
** byteOut1 &= ~(1 << n); // set to 0;**
** }**
** stateCount++;**
** }**
** // second byte**
** for (int n = 0; n < 7; n++) {**
** if (bState[stateCount] == B1) {**
** byteOut2 |= (1 << n); // then set to 1;**
** }**
** else {**
** byteOut2 &= ~(1 << n); // set to 0;**
** }**
** stateCount++;**
** }**
** // third byte**
** for (int n = 0; n < 7; n++) {**
** if (bState[stateCount] == B1) {**
** byteOut3 |= (1 << n); // then set to 1;**
** }**
** else {**
** byteOut3 &= ~(1 << n); // set to 0;**
** }**
** stateCount++;**
** }**
** // fourth byte**
** for (int n = 0; n < 7; n++) {**
** if (bState[stateCount] == B1) {**
** byteOut4 |= (1 << n); // then set to 1;**
** }**
** else {**
** byteOut4 &= ~(1 << n); // set to 0;**
** }**
** stateCount++;**
** }**
** // fifth byte (shorter than others)**
** for (int n = 0; n < 4; n++) {**
** if (bState[stateCount] == B1) {**
** byteOut5 |= (1 << n); // then set to 1;**
** }**
** else {**
** byteOut5 &= ~(1 << n); // set to 0;**
** }**
** stateCount++;**
** }**
** // send the values over serial to Processing**
** Serial.print(byteOut1, BYTE);**
** Serial.print(byteOut2, BYTE);**
** Serial.print(byteOut3, BYTE);**
** Serial.print(byteOut4, BYTE);**
** Serial.print(byteOut5, BYTE);**
** Serial.print(stopByte, BYTE);**
}
[/quote]

I suspect that you have used up all your RAM, although I've never heard that that could cause upload errors. (Your program is compiling fine, but the Arduino SW is having a problem loading into the AVR.) Counting

int stateMatrix[32][8]   // !! 512 bytes (and not all initialized!)

int averages[32] = {    // 64 byte
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0};          


boolean bState[32] = {   // 32 bytes
 B0, B0, B0, B0, B0, B0, B0, B0,
 B0, B0, B0, B0, B0, B0, B0, B0,
 B0, B0, B0, B0, B0, B0, B0, B0,
 B0, B0, B0, B0, B0, B0, B0, B0};


void setup() {

 Serial.begin(9600);   // 128 bytes for the serial buffer...

I dunno. A bit close for comfort ?

Followup: I copied it into Arduino14 on my Mac and uploaded it to a MDC BBB without any problems... It even seems to run ok (characters displayed in serial monitor panel.) Works with Arduino12 too.

MDC BBB?? What does this mean? Forgive my ignorance. BTW I am using a 168 chip on a decimilia board

BBB is this board: http://moderndevice.com/

I am not sure if westfw has a put a 328 in his board, but I tried that sketch on an Arduino with a 168 chip and it uploads and sends serial data.

double check you have the correct board selected in your IDE.

I hate Vista. The code runs fine on my XP machine. I have the board selected as Decimilia on both machines. Mem, is the clock still ticking?

is the clock still ticking?

It certainly is :)