Repository navigation
Conversation
Update the D4-D7 data lines before toggling E high in hd44780_xmit_bits(), instead of raising E first and changing the data lines while E is already high. On non-AVR boards the E pulse width and all other timing are unchanged. A WINSTAR 1604 (16x4) display, as fitted to the XYZprinting da Vinci 1.0A, showed garbled characters with the previous ordering, and could remain stuck in its power-on one-line mode. Lengthening the E pulse to 5us with the previous ordering did not help. With the data lines set before E rises the display works at the existing timing, both after a FIRMWARE_RESTART and after a cold power-on. This is still within the HD44780 write timing (the data remains valid well before E falls), and matches the order used by the Arduino LiquidCrystal library and Repetier-Firmware. On AVR, ndelay() does not delay, so the E pulse width came from the time spent updating the data lines while E was high. Add a short nop delay there (as in sensor_hx71x.c and sensor_cs1237.c) so the E pulse is not shortened by this change. Signed-off-by: Joel Pratt <catawalks@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This moves the D4–D7 update in hd44780_xmit_bits() to before E is raised HIGH.
The existing sequence appears to meet the HD44780 write timing: data needs to be valid only for tDSW before E falls. However, the WINSTAR display tested here appears to require valid data when E rises. With the change, the data is stable for the entire E pulse. This is also the sequence used by Arduino’s LiquidCrystal library and Repetier-Firmware’s HD44780 driver.
Changing just the order would bring up an issue on slower AVR MCUs that didn't require a delay.
ndelay()is a no-op, so the E pulse width came from the time spent updating the data lines while E was high. With the data lines set up before the E toggle it basically would have put the toggles back to back and not had enough time delay. Adding the nop delay (the same as in sensor_cs1237.c) adds the needed time delay back for AVR boards allowing proper timing. This is calculated by disassembly but is otherwise untested as I don't have an AVR board to test with.Tested on a XYZprinting da Vinci 1.0A with a SAM3X8E mainboard and stock WINSTAR 1604 (16×4) display, configured as:
The board’s LCD R/W line is held low with a static_digital_output.
Results:
The display works at the existing timing after both FIRMWARE_RESTART and a cold power-on, including menu navigation. Increasing the E pulse by more than 20x did not resolve the issue with the original sequence.
I’ve only tested this one display, so reports from owners of other HD44780-compatible displays would be helpful. This change should not negatively affect any HD44780 compatible screens, theoretically it should only increase compatibility of clones.