Hello, I have a custom atmega328p based board. It works great as is, But I didn't add support for an RX/TX serial communication pad due to space constraints. What I want to do is use the SPI (13,12,11,10) pins that I use to program the microcontroller to interface with the Serial monitor in the Arduino IDE. I'm pretty sure this is possible because the The SPI and UART protocols on the pins will not simultaneously. The Serial data will be sent from the target, then to the programmer (Arduino uno) and then to the Serial Monitor. I don't really know where to start besides using the software serial library. Any help appreciated.
I'm just using the example code for SoftwareSerial
#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 12); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
mySerial.println("Hello, world?");
}
void loop() { // run over and over
if (mySerial.available()) {
Serial.write(mySerial.read());
}
if (Serial.available()) {
mySerial.write(Serial.read());
}
}
RX/TX are pins PD0 & PD1. On the board that I have they do not have solder pads to connect to. I want to use the IDE serial monitor to for debugging. So instead I want to use software serial on PB3 & PB4.
When I tried it originally, I got nothing in the serial monitor.
How about you first try out the sample sketch on a board that does have Serial. Connect the programmer to the swSerial pins. open 2 instances of the IDE and set them to a Serial port each. (with the correct baud-rate) open up the Serial monitor 2x, and reset the board.
Ah, SoftwareSerial. You failed to mention that initially.
And how does the above statement tie in the schematic fragment you've shown above? Where is this "target"? Is it the 328P you're showing? Or is that supposed to be the programmer/Arduino Uno? I'm still in the dark.
Not all pins on the Mega and Mega 2560 boards support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).