OK, so I am setting up a Nano328 to test a DRAM chip ( Dynamic RAM Memory ).
The code I am using uses PORTD for convenience. The problem is unless I am missing the point, that PORTD includes the use of D0/D1 which is normally used for Comms. This is ok, but if I get a failure and want to report the failure back to the monitor, I need those TX/RX pins back.
So on failure once I have finished using them as digital pins for the code, I tried to Serial.begin( baud ) and then Serial.println("my failure message"); but it does not work and I still get rubbish on the monitor.
Is there a way around that ( which does not mean me having to rewrite the code and rewire everything which would be a real pain .
Here is the last part of the code where a failure occurs. and this is when I want to stop using the RX/TX for Data pins and back to normal RX/TX
digitalWrite(DIN, val);
for (int col=0; col<COLROW_COUNT; col++)
for (int row=0; row<COLROW_COUNT; row++)
writeToRowCol(row, col);
digitalWrite(DIN, !val);
for (int col=0; col<COLROW_COUNT; col++)
for (int row=0; row<COLROW_COUNT; row++)
if (readFromRowCol(row, col) != val){
//THIS IS A FAILURE AND WE WANT TO SEND A MESSAGE BACK TO THE MONITOR
Serial.begin(115200);
Serial.print("COL ADDR : "); Serial.print(col);Serial.println("");
Serial.print("ROW ADDR : "); Serial.print(row);Serial.println("");
Serial.end();
fail();
}
return;
}
Actually, I did a simple replica of this in a new sketch, and it does in fact work. I think what is happing is that as the monitor is open when the program is running, it is totally swamped with a massive line of garbage and when the real message comes in at the end, it simply wont print it.
I've tried clearing the screen by printing 100 new lines, but that does not take it either.
Please read the forum guide. Code tags should always be used when posting code.
Posting code fragments severely limits the help that forum members can give you. It's better to post complete code if you can. This can be a cut-down version of your code that is enough to demonstrate the problem.
If other components are connected to the Tx/Rx pins, this may prevent serial communications from working, unless those components are high impedance.
OK, I added a an enclosing code tag, not sure if that is what you wanted.
This is a large program and reducing it would have been to much work. However, I take your point for next time.
The outputs of the RX/TX ( D0/D1) pins go to the addresses input pins of a DRAM CHIP along with the other 6 data lines from assigned to PORTD. This is normal practice and they will have no effect on the output as was demonstrated by doing a simple test of this in another script where it all worked.
Unsurprisingly I guess there is no answers so far. - Thanks anyway.
The problem was a mess-up on my behalf actually, I made a mistake in one of the control pin assignments, so the print block was never reached.
So, in short, you can use TX/RX as a data pin an Visa Versa, just not while you are using them as a Serial Comms pair. This is extremely useful to know that I can do that now I can send messages back on a failure.