Arduino serial monitor outputs garbage with SPI hw libraries

Thread Starter

joblake326

Joined Jan 9, 2022
21
I have a sketch that interfaces my MEGA board with a 4" TFT touch (ILI9486).
That part has been working fine but I just noticed that the serial monitor doesn't work anymore. It's displaying ⸮⸮⸮⸮⸮όS⸮⸮⸮⸮⸮⸮⸮ތ junk.
I've narrowed it down to:
#include <LCDWIKI_SPI.h> //Hardware-specific library
It appears to be hosing communications with the serial monitor because if I comment it and all references to it, serial monitor works.
Just for the heck of it I installed a different SPI hw library: ILI9486_SPI.h.
I tried one of its examples and the serial monitor put out junk for that one too.
I'm new at this stuff but seems like the serial communications for SPI are interfering serial comm for the serial monitor,
Maybe?
 

Papabravo

Joined Feb 24, 2006
21,159
I have a sketch that interfaces my MEGA board with a 4" TFT touch (ILI9486).
That part has been working fine but I just noticed that the serial monitor doesn't work anymore. It's displaying ⸮⸮⸮⸮⸮όS⸮⸮⸮⸮⸮⸮⸮ތ junk.
I've narrowed it down to:
#include <LCDWIKI_SPI.h> //Hardware-specific library
It appears to be hosing communications with the serial monitor because if I comment it and all references to it, serial monitor works.
Just for the heck of it I installed a different SPI hw library: ILI9486_SPI.h.
I tried one of its examples and the serial monitor put out junk for that one too.
I'm new at this stuff but seems like the serial communications for SPI are interfering serial comm for the serial monitor,
Maybe?
It is not uncommon for a set of pins on a processor to have multiple functions. Libraries designed for a particular platform, may or may not work when ported to other platforms. How about more details on your particular platform (MEGA board?)
 

Thread Starter

joblake326

Joined Jan 9, 2022
21
It's an Elegoo Mega 2560.

This is the code that's causing the problem.
#include <LCDWIKI_SPI.h> //Hardware-specific library
#define MODEL ILI9486_18
//pins on the MEGA
#define CS A5
#define CD A3
#define RST A4
#define LED A0 // need this
//the definitions of hardware spi mode as follows:
LCDWIKI_SPI mylcd(MODEL, CS, CD, RST, LED); //model,cs,dc,reset,led

I tried assigning other pins for CS, CD, RST, LED but it did the same thing.
 

Thread Starter

joblake326

Joined Jan 9, 2022
21
It is not uncommon for a set of pins on a processor to have multiple functions....
Well I figured it out but I can't explain why it behaved the way it did.
I had a function with 2 missing curlys---that did NOT produce an error when compiling. It was a Case Switch inside of a FOR inside of an IF ELSE.
Very weird indeed.
 

Papabravo

Joined Feb 24, 2006
21,159
Well I figured it out but I can't explain why it behaved the way it did.
I had a function with 2 missing curlys---that did NOT produce an error when compiling. It was a Case Switch inside of a FOR inside of an IF ELSE.
Very weird indeed.
Good to know. When things that used to work stop working, you must question EVERYTHING.
 

Thread Starter

joblake326

Joined Jan 9, 2022
21
Yeah. Upon further soul searching, here is the series of unfortunate events:
1. The TFT display worked fine.
2. I broke the code but the compiler didn't care.
3. The TFT display stopped working as a result of the above.
4. I said let me whip out the serial monitor to see what's going on.
5. Monitor said ⸮⸮â®ÞŒ
6. I forgot that the TFT wasn't working. That would've been helpful : 0
7. I spend the next 3 hours barking up the wrong code. HW library? Yeah. That's the ticket.
8. I try another example sketch with the same libraries that I blamed for the problem.
9. They worked fine---both TFT and serial monitor.
10. I then started commenting out my functions one by one and narrowed it down to one.
11. In the process of analyzing the code in this function I happened to notice that the FOR had no {
12. Tried compiling again and it said, "Good work". Go ahead and upload it".
13. WTH?
14. Put in the missing {.
15. Compiler says, "Not this time idiot".
16. WTH?
17. I remove a } that seemed out of place.
18. Success!!
The sketch was stuck in some super tight loop and sucked up all the resources, leaving the serial monitor in the dust.
Well, that's an afternoon I'll never see again.
 
Top