Hi,
for Debugging on an ATtiny84 I want to use SoftwareSerial to print to Serial Monitor. For programming the ATtiny I use an USBasp connected to MISO, MOSI, USCK. To save pins SoftwareSerial also shall use MISO and MOSI. On the ATtiny84 pin numbers are 5=MISO=RX and 6=MOSI=TX.
For testing I wrote the following sketch:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(5, 6); // RX, TX
uint32_t baudrt;
uint16_t lcnt = 0;
uint8_t val8;
uint16_t val16;
uint32_t val32;
void setup() {
// put your setup code here, to run once:
baudrt = 38400;
mySerial.begin(baudrt);
mySerial.println();
mySerial.print("Baudrate=");
mySerial.println(baudrt);
char vc = ' ';
char vstrg[24];
val16 = 134;
strcpy(vstrg, "hello world!");
// block 1:
// while (1) {
// mySerial.print(val16);
// mySerial.print(vc);
// mySerial.println(vstrg);
// }
// block 2:
for (int i = 0; i < 3; i++) {
mySerial.print(val16);
mySerial.print(vc);
mySerial.println(vstrg);
}
// block 3:
// lcnt = 0;
// while (1) {
// if (lcnt == 0) mySerial.println("jetzt while");
// lcnt++;
// mySerial.print(val16);
// mySerial.print(vc);
// mySerial.println(vstrg);
// if (lcnt == 5) break;
// }
}
void loop() {
// put your main code here, to run repeatedly:
}
Setup() contains 3 blocks of code. With block 1active (the others are commented out) Serial Monitor shows the outputs of this code. Because the screen fills so rapidly, I cannot see if output of baud rate is on the screen.
With only block 2 or alternatively only block 3 active there is no output at all.
When I close the Serial Monitor and show the outputs with a terminal program, e.g. Tera Term, everything is ok with all blocks.
I cannot understand what happens here. Can somebody explain it to me?