Teensy 4.0 - I2C Lcd - Character Corruption with LCDMenuLib2

Status
Not open for further replies.

relentlessly

New member
Hello All,

my project is still in its initial phases and I just recently switched from a regular Arduino uno v3 to a teensy 4.0.
While adjusting things for the 3.3v teensy I had issues with my LCD and LCD backpack.

After realising that the voltage needed translation a logical level converter was purchased (https://www.sparkfun.com/products/12009)
I configured the logic level converted and set everything up.

I loaded the default i2c menu example from the menu library I am using: LCDMenuLib2 [https://github.com/Jomelo/LCDMenuLib2]
this example to be precise: https://github.com/Jomelo/LCDMenuLi...es/03_displaytypes/lcd/LCDML_i2c_display_20x4

after uploading the example to the teensy, I noticed that I was getting strange LCD character corruption. The characters displayed were not the ones asked for, but seem to be random other ascii chars.

74388065-64503f00-4dc8-11ea-85aa-a7a07bf6dcd1-small.jpg

I was confused and though there was a hardware problem, or the logical level converter was mis configured, but this particular library and example has a "screen saver" that puts text on screen after 10 seconds of inactivity
and much to my supprise the screen saver text is correct

74388075-6b774d00-4dc8-11ea-90c9-dafbd0e4fb57-small.jpg

I have now tried setting the teensy to multiple different MHz speeds: 24, 150, 396,600
with the same results in all cases.

I have tested everything with a basic I2c example : https://github.com/johnrickman/LiquidCrystal_I2C/tree/master/examples/HelloWorld
which works fine at all speeds. so it does not appear to be a hardware issue or a i2c timing issue, at least not a first glance

I posted an issue on the menu library GitHub, but have not heard anything :https://github.com/Jomelo/LCDMenuLib2/issues/54
so I though I would take a chance on this forum and see if maybe someone here has any suggestions.

thanks

Arduino ide 1.8.10
teensyduino 1.4.8
Robojax I2C Serial Interface Module for LCD1602 LCD Display -> lcd backpack uses: PCF8574T
20x4 LCD [https://www.adafruit.com/product/198] -> Standard HD44780
 
The first thing I would recommend is trying to run it on the current up to date versions of teensyduino
That is you might try Teensyduino 1.50 or 1.51.beta1... As some things have been fixed for I2C (Wire) in later builds...
 
Thank you for the idea.

Upgraded to Arduino IDE 1.8.11
and teensyduino 1.50

The problem still occurs. The gibberish chars seem to have changed.
I tried beta1, no dice.

The "screensaver" now seems to be broken and never appears, even after the 10 seconds
and there is now a bunch of warnings? in the arduino after compiliation, which seem worrying

specifically this one:
Code:
strcpy_P(var, (char*)pgm_read_word(&(g_LCDML_DISP_lang_ ## lang ## _table[id])));

So changing versions of teensyduino has had an effect, just not the one I was hoping for.


Code:
In file included from C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src/LCDMenuLib2.h:178:0,

                 from C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\examples\03_displaytypes\lcd\LCDML_i2c_display_20x4\LCDML_i2c_display_20x4.ino:16:

C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src/LCDMenuLib2_macros.h:111:52: warning: backslash and newline separated by space

             parent.addChild(parent ## _ ## child); \            

                                                    ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/WProgram.h:41:0,

                 from C:\Users\Jason\AppData\Local\Temp\arduino_build_576248\pch\Arduino.h:6:

LCDML_display_menu: In function 'void lcdml_menu_display()':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/avr/pgmspace.h:108:2: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

 })

  ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/avr/pgmspace.h:59:45: note: in definition of macro 'strcpy_P'

 #define strcpy_P(dest, src) strcpy((dest), (src))

                                             ^

C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src/LCDMenuLib2_macros.h:66:38: note: in expansion of macro 'pgm_read_word'

                 strcpy_P(var, (char*)pgm_read_word(&(g_LCDML_DISP_lang_ ## lang ## _table[id]))); \

                                      ^

C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src/LCDMenuLib2_macros.h:104:9: note: in expansion of macro 'LCDML_getCustomContent'

         LCDML_getCustomContent(lcdml, var, id)

         ^

C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\examples\03_displaytypes\lcd\LCDML_i2c_display_20x4\LCDML_display_menu.ino:50:13: note: in expansion of macro 'LCDML_getContent'

             LCDML_getContent(content_text, tmp->getID());

             ^

In file included from C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src\LCDMenuLib2.h:178:0,

                 from C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src\LCDMenuLib2.cpp:38:

C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src\LCDMenuLib2_macros.h:111:52: warning: backslash and newline separated by space

             parent.addChild(parent ## _ ## child); \            

                                                    ^

C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src\LCDMenuLib2.cpp: In member function 'void LCDMenuLib2::loop_menu()':

C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src\LCDMenuLib2.cpp:191:13: warning: unused variable 'stop_while_loop' [-Wunused-variable]

     boolean stop_while_loop = false;

             ^

C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src\LCDMenuLib2.cpp: In member function 'void LCDMenuLib2::MENU_doScroll(uint8_t)':

C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src\LCDMenuLib2.cpp:1045:13: warning: variable 'update' set but not used [-Wunused-but-set-variable]

     boolean update = false; 

             ^

C:\Users\Jason\Documents\Arduino\libraries\LCDMenuLib2\src\LCDMenuLib2.cpp:1046:13: warning: unused variable 'child_cnt' [-Wunused-variable]

     uint8_t child_cnt = MENU_countChilds(curMenu);   

             ^

Opening Teensy Loader...

Sketch uses 30288 bytes (1%) of program storage space. Maximum is 2031616 bytes.
Global variables use 41660 bytes (7%) of dynamic memory, leaving 482628 bytes for local variables. Maximum is 524288 bytes.
 
After realising that the voltage needed translation a logical level converter was purchased (https://www.sparkfun.com/products/12009)
I configured the logic level converted and set everything up.

Glad your problem is solved. Just a minor quibble. I2C has open drain connectors on the clock and data lines. As far as I can tell. all you need do is tie SDA and SCK to the 3.3V line through, for example, 4.7k pull-up resistors, obviating the need for a level translator.
 
Status
Not open for further replies.
Back
Top