LiquidCrystal library

Post Reply
Phono
Posts: 92
Joined: Tue May 05, 2015 6:08 am
Location: Ermont, France

LiquidCrystal library

Post by Phono » Fri Sep 29, 2017 3:41 pm

Hi,
I am in the process of migrating from the Maple IDE to the Arduino for STM32 IDE, and I had a problem with this library.
I am using a 3.3V, 2 x 16 character LCD module.
It worked with the Maple library, but would only display garbage in the Arduino environment.
I compared my source files, new version against current one, but no difference could explain it.
Then I compared the LiquidCrystal library of Arduino for STM32 against that from Maple, and again, no other difference than those required to run in the new environment.
Then I tried to tweak the value of the many delay() calls, and I found this:
In the following function :

Code: Select all

void LiquidCrystal::pulseEnable(void) {
  // _enable_pin should already be LOW (unless someone else messed
  // with it), so don't sit around waiting for long.
  digitalWrite(_enable_pin, LOW);
  delayMicroseconds(1);

  // Enable pulse must be > 450 ns.  Value chosen here according to
  // the following threads:
  // http://forums.leaflabs.com/topic.php?id=640
  // http://forums.leaflabs.com/topic.php?id=512
  gpio_toggle_bit(PIN_MAP[_enable_pin].gpio_device, PIN_MAP[_enable_pin].gpio_bit);// togglePin(_enable_pin);
  delayMicroseconds(2);
  gpio_toggle_bit(PIN_MAP[_enable_pin].gpio_device, PIN_MAP[_enable_pin].gpio_bit);// togglePin(_enable_pin);

  // Commands needs > 37us to settle.
  delayMicroseconds(42);
}
I increased the last delay and I found that 48 µs were the minimum value to have my LCD module work properly.
So I set it to 50.
Since 42 is the value used in the Maple library, can we conclude that the function delayMicroseconds() does not give the same duration in the two environments?
May I suggest that this delay be increased to 50 in the public library?
No doubt that I found a LCD controller chip that was a bit lazy, but for sure this increase is required, and does little harm to the application that uses it.

User avatar
RogerClark
Posts: 7485
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: LiquidCrystal library

Post by RogerClark » Fri Sep 29, 2017 8:47 pm

Thanks

delays like that seem suspicious to me..


I agree the library should be updated to a value that works...

Phono
Posts: 92
Joined: Tue May 05, 2015 6:08 am
Location: Ermont, France

Re: LiquidCrystal library

Post by Phono » Sun Oct 01, 2017 9:08 pm

It is very likely that the delayMicroseconds() function gives with the STM32 for arduino shorter delays than in the Maple library. Supposing they were correct in the Maple library, could we correct the timings in the STM32 for arduino?

fpiSTM
Posts: 250
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: LiquidCrystal library

Post by fpiSTM » Sun Oct 01, 2017 9:39 pm


User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: LiquidCrystal library

Post by Pito » Mon Oct 02, 2017 6:16 am

It is very likely that the delayMicroseconds() function gives with the STM32 for arduino shorter delays than in the Maple library.
You may measure the real delay's duration with high precision:
viewtopic.php?f=18&t=2004&p=26692&hilit=pito+dwt#p26692
Pukao Hats Cleaning Services Ltd.

Post Reply