Skip to content

LCD Begin calls delayMicroseconds(50000) which is outside the maximim value of 16,384. (AVR) #86

Open
@NormanDunbar

Description

@NormanDunbar

The LCD begin() function makes a call to delayMicroseconds() passing 50,000 as the delay parameter:

// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
// according to datasheet, we need at least 40 ms after power rises above 2.7 V
// before sending commands. Arduino can turn on way before 4.5 V so we'll wait 50
delayMicroseconds(50000);

This exceeds the maximum value of 16,384 according to the delayMicroseconds() docs.

The 50,000 value will be doubled to 100,000 but because it overflows, the doubling will actually result in 34,464. This will then be doubled to 68,928 and again, overflow to only 3,392 microseconds. The docs for the LCD specify that a delay of 40.1 milliseconds or greater is required, the delayMicroseconds() function is unable to provide such a delay.

It appears as if the LCD has been properly initialised well before the begin() function is called. However, I would suggest the following code replace the delayMicroseconds(50000); call at line 107 in LiquidCrystal.cpp:

delayMicroseconds(12500);
delayMicroseconds(12500);
delayMicroseconds(12500);
delayMicroseconds(12500);

Which should give the required 50,000 uSecond delay. (Alternatively, use any combination that adds up to 50,000!)

Additional context

Additional reports

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions