Why is serial communication stopped working when tft display is initialized?

Status
Not open for further replies.
Hi

I have two teensy4.1 devices, where 1 acts as sender and the other as receiver.
They are connected together with a SP3485 IC.
Both are using Hardware Serial Port 4 to communicate.

The communication works as long as I don't have the tft display activated.
I don't even have to display something on the tft. It is already enough in the setup() function to have this line: "uint16_t ID = tft.readID();"
As soon as I activate this line, I receive only 1 round of data and then the communication stops.
When I comment out the line then the communication flow works again.

In the lib_deps I have two libraries
Code:
lib_deps =
    adafruit/Adafruit BusIO @ ^1.8.3
    adafruit/Adafruit GFX Library @ ^1.10.10

In the lib folder I have this Library:
https://github.com/prenticedavid/MCUFRIEND_kbv
I have made a slight modification in the lib on mcufriend_shield.h (subfolder = utility).
This was necessary to adopt it to my own PCB design.

I pusblished my project on GitLab in this group: https://gitlab.com/solarpanel1
The current error is in the blue SolarTracer_Gartenhaus (receiver) program.
Branch = dev or main. They have both the same content.

The sender program is the green SolarTracer_SolarPanel
The receiver program is the blue SolarTracer_Gartenhaus

Also the schematics for sender and receiver are on GitLab.

It would be nice when someone could help me to identify the problem with the communication, as I don't see why the communication stops working when the tft is activated.

Best regards

Simon
 
Sorry not sure exactly what is going on or what you tested...

But your code has things like:
Code:
    while(!Serial) {
        ; // wait for serial port to connect. Needed for native USB
    }
So if you do not have the board plugged in to Serial and a Serial terminal open, your code will never make it out of Setup() so loop will never run
 
Dear KurtE

Thanks for your feedback.
I'm aware of the "while(!serial){.." statement.
I have this line because I eventually would miss the line, where the tft ID is printed.
So when I open up the serial monitor then it works through the setup() part and through the loop().
But It only retrieves the data once. I can see that the loop is still running because I have a test print in the Loop "Test, if Loop works".

This is the terminal output when "uint16_t ID = tft.readID();" is enabled.
Also the first few letters seems to be corrupted somehow.

Code:
‚ŌŠĒŌŠēRtemp_23.0°C
date_20.09.2021
date_20.09.2021
Test, if Loop works
Test, if Loop works
Test, if Loop works
Test, if Loop works
Test, if Loop works
Test, if Loop works
[..]

This is the terminal output when "uint16_t ID = tft.readID();" is commented out.
(Serial.println("Test, if Loop works"); is also commented out).
Wrong character "Â" needs also a correction.

Code:
temp_23.2°C
date_20.09.2021
date_20.09.2021
time_21:03:02
temp_23.2°C
date_20.09.2021
date_20.09.2021
time_21:03:02
temp_23.2°C
date_20.09.2021
date_20.09.2021

p.s. I have now also commented out the while not Serial lines. To be 100% sure that I don't stumble over this.
// while(!Serial) {
// ; // wait for serial port to connect. Needed for native USB
// }
 
Yep: most of mine I put in have timeouts... like: while (!Serial && millis() < 5000) ;
This will wait up till 5 seconds from the time the teensy starts until it has terminal monitor...
 
Thanks

I've updated my code.

Just a side question.
Usually the while loop have braces.
Here from the Arduino syntax reference:
Code:
while (condition) {
  // statement(s)
}

But you don't have the braces.
I have seen several examples like your's without the braces. Therefore I'm wondering if it's just a short form or when no statements are needed that the braces can be omitted?

Code:
while(!Serial && millis() < 5000) ;
vs.
Code:
while(!Serial && millis() < 5000) { ; }

----

And I have also figured out why there was "temp_23.2°C".
It was simply because I've used tyCommander and had not selected the UTF-8 charset :).
But the 'corrupted' characters at the beginning are still present when tft is enabled.
Code:
�}�6.2°C
date_20.09.2021
date_20.09.2021
time_23:06:31

Still not running without any clue why the "uint16_t ID = tft.readID();" stops the serial receiving.
I have adjusted my coding and commited to GitLab to main and also to dev.

The tft is this model from Kuman
 
Last edited:
Sorry, there is lots of stuff here that I have not used... Like this display, or library or...

But for example: the mcufriend_special_3.h file has some areas commented out for T4.x...
Code:
//####################################### TEENSY 4.0 ############################
#elif defined(__IMXRT1062__) // regular UNO shield on a Teensy 4.x
#warning regular UNO shield on a Teensy 4.0

//LCD pins  |D7  |D6  |D5 |D4 |D3 |D2 |D1  |D0  | |RD  |WR  |RS  |CS  |RST |  A5
//MXRT pin  |7.17|7.10|9.8|9.6|9.5|9.4|7.11|7.16| |6.18|6.19|6.23|6.22|6.17|6.16
//4.x pins  |7   |6   |5  |4  |3   |2  |9  |8   | |14  |15  |16  |17  |18  |
And assuming this code uses these pins... The pins 16 and 17 are Serial4...

But again there are lots of bits and pieces hard to know.

Sorry, I know not much help
 
Hi KurtE

Thanks for pointing this out. Seems you are right.
It is my Dad and me who have the same setup with similar code.
Therefore we have the shared GitLab repository. And both of us has his own file in the src folder and working with the src_filter = +<*> -<*Name*> in platformio.ini.
So we don't have to shuffle the files back and forth everytime.

He has already tested with his setup with Serial8 7 and 6 and they work all.
Think I have to redisgn the PCB and order new ones :)
 
Thank you :)

Hopefully it will ever be finished.
It is for a solar collector panel which adjusts to face the sun.
I'll upload also some CAD files soon :)
 
Just two impressions.
The movements are done with a linear actuator and a stepper motor.
2021-09-21 21_43_18-SOLIDWORKS Premium 2021 SP4.1 - [SolarPanelTracker.SLDASM].jpg2021-09-21 21_43_45-SOLIDWORKS Premium 2021 SP4.1 - [SolarPanelTracker.SLDASM].png
 
Normally we don't close out threads, except for SPAM types or if someone opens up several threads...

Besides will be fun to hear of your progress later.

Again good luck
 
Have already my first update.

I've made a PCB for the teensy4.1 with headerpins to fit exactly to the Kuman tft display.
DSC_0002.jpg DSC_0005.jpg DSC_0008.jpg DSC_0009.jpg

I had already ordered the red pjrc ili9341 tft before,
but somehow we decided to use the Kuman instead of the pjrc one. Maybe because my Dad had only the Kuman.
But now I've made an adapter to try the pjrc tft and it works perfect together with hardware serial port 4 :)
See last picture with the not so beautyful adapter :p. Now I will do the necessary changes in the PCB design so it fits to the tft from pjrc.
DSC_0010.jpg

There is one thing I'm confused, because there are two libraries.
This one
https://github.com/PaulStoffregen/ILI9341_t3
and this one:
https://github.com/KurtE/ILI9341_t3n

I'm not sure which one I should use. I see that only the first is mentioned on the pjrc website but the t3n library works well with this tft.
I see that you are a contributor in both repositories. Maybe you can give me an advise which one to use?

Best regards
Simon
 
Status
Not open for further replies.
Back
Top