I've come across something that's puzzling me and is preventing me progressing very far!. As a demo, I'm using the following code:
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
Serial.println("Testing 1, 2, 3");
Serial.println("Testing 4 5, 6");
Serial.println("Testing 7, 8, 9");
Serial.println("Testing 10, 11, 12");
Serial.println("Testing 13, 14, 15");
}
void loop() {
Serial.print("Loop");
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000);
}
It doesn't print from loop() and the LED doesn't blink. If I comment out a few of the "Testing..." lines, it runs through as I'd expect and the LED flashes.
version 1.0 - just the Serial Monitor, no physical hardware.
Edit: I've just tried it on the laptop and it works perfectly. I've checked that I have the latest motherboard drivers installed but re-installed them anyway. I've also re-installed the Arduino USB driver. I've even unplugged all other USB devices (except the mouse).
struct ring_buffer
{
unsigned char buffer[RX_BUFFER_SIZE];
// volatile int head; // Original declarations
// volatile int tail;
unsigned char head; // New declarations cause the problem
unsigned char tail;
};
I'm not sure what the connection is but I have tried "old" and "new" declarations a few times which seems to confirm it. Maybe someone else would like to confirm it's the case.
With the original declarations, the sketch used 2688 bytes. With my faulty modification, it used 2486 and with your working version, it 2506 bytes. So the saving in memory isn't quite as great (180 bytes versus 202) but it works
For consistency, I think I'll stick with the original unless I get desperate for memory.
I'm happy programming in Delphi (Pascal) which is sufficiently different to C/C++ to confuse me!