Newhaven Display Forum

Newhaven Products => Character LCDs => Topic started by: camac881 on November 11, 2014, 02:05:13 PM

Title: NHD-0420D3Z-FL-GBW-3V Dropping characters over I2c
Post by: camac881 on November 11, 2014, 02:05:13 PM
Hello All,
  I saw the other posts about losing characters over I2c due to firmware issues and tried the same fix by slowing it down. It has gotten better but I'm still dropping the occasional character. I am running the screen from an Arduino Uno and displaying data from an SPI A/D converter.

 My question is what is the correct way to code a speed correction for the Arduino? The line I'm using now is
#define TWI_FREQ = 100000L / 6; Is that correct?

Thanks,
Cam
Title: Re: NHD-0420D3Z-FL-GBW-3V Dropping characters over I2c
Post by: Michael_L on November 11, 2014, 03:12:01 PM
I'm not sure if this applies to the Uno as well as the Mega, but with the Arduino Mega I have used "TWBR = 152;" (sets I2C clock frequency to 50kHz) after I call "Wire.begin()" in the setup() function.
I would check the Arduino forums/documentation to confirm this works with the Uno too.
Title: Re: NHD-0420D3Z-FL-GBW-3V Dropping characters over I2c
Post by: camac881 on November 12, 2014, 08:16:37 AM
Hello Michael,
  That worked perfectly. Thank you.

  I checked the Wire library reference at Arduino.cc and they referenced the data sheet at Atmel and a table that does not make this any clearer. How do you come up with the number? Do you gather all the pieces and run them through the formula? It seems like herding cats to me.

Thanks for your help!
Cam

Title: Re: NHD-0420D3Z-FL-GBW-3V Dropping characters over I2c
Post by: Michael_L on November 14, 2014, 09:41:07 AM
You're welcome!  This site should help:

http://www.gammon.com.au/forum/?id=10896 (http://www.gammon.com.au/forum/?id=10896)