-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Struggeling with i2c/TWI communication on nRF52 DK (based on nRF 52832) and SH1106 132x64 OLED display #1377
Comments
I just compared the i2c traced between Arduino and nRF and saw something but can't make a clue out of it: Arduino first byte of init sequence: nRF first byte of init sequence: Why is this 0x00 not send by the library before the 0xae? Also I wonder why I have to explicitly set the i2c address to 0x3c in the initialization of the library. This is not needed on the Arduino part? If I don't call u8g2_SetI2Caddress(0x3c), the i2c address is preset to 0xff? Am I missing something during the initialization?
|
OK the interleave was due to the logging messages... yet the display is still totally distorted... |
Problem solved... I had initially commented out the printhello() and apparently the garbled screen was just what was in the displays memory. After activating the printhello() again I see a proper printout! Everything seems to work! Awesome library! Now I'm trying to get it to work in non-blocking mode! |
U8g2 internally works with the left aligned address, this means it not 0x3c, but 0x3c*2. For the uC specific I2C produres you probably need to device the u8g2 internal address by 2: Line 1336 in 3c6460a
This is also documented in the reference manual: There had been a lot of discussion in history regarding the i2c address, so please excause, it the multiplication with two is confusing (see also here: #821)
To me it is not clear, what you mean by "the library". No doubt, the 0x00 byte MUST be there. This byte is either 0x00 or 0x80 and specifies how to interpret other bytes after this command (see also the controller specification).
Oh, ah, I just started to read all you posts. |
Love to! Here it is!
|
Thanks! |
My pleasure! Thanks for YOUR great work with this library! Link to my github https://github.com/OevreFlataeker/u8g2_nrf52 |
I am trying to use the u8g2 library on a nRF52 DK (ARM M4 based) to interface a SH1106 OLED. Before starting I verified the OLED is working perfectly on an Arduino with the following calls:
Then I read through the FAQ and Porting Guides.
I understand I need to implement a GPIO and wait routine and a handler for the HW. I haven't used the TWI peripheral on the nRF chip before but it seems to not be too complicated.
I am able to interrogate the TWI bus and identify the chip at address 0x3c with the nRF -> Timing, Level and general TWI seems to work.
When I then issue the following calls
I get a fatal error form the nRF TWI subsystem on the call to u8g2_InitDisplay(), the proplem is a NACK.
I then analyzed the timing and identified the following communication.
I am not sure if this is correct. After the ACK on address 0x3c I get a NACK on the read 0x40 (I read one byte during the ID scan).
When the actual InitDisplay() is called and I see the following I/O:
and the output of my code on the console
I've tried to interface the TWI peripheral in blocking and non-blocking mode as blocking should be easier but more CPU consuming. However both showed the same result. The following code shows my blocking I/O attempt. I tried both 100kHz as well as 400 kHz communication. In both attempts it's the same behavior.
I wonder if it is ok that the CLK signal looks to be as if it is a tiny bit shifted? However I don't have any control on this, so I would not know what to do if that is an issue. I wonder if the DNACK is something I need to care for or configure if I need to ignore it or anything?
The code for the u8x8_HW_com_nrf52832 I basically copy/pasted and adapted to the nRF SDK. I am using the nRF SDK 17.02. The description of using the TWI master mode is here: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.0.0%2Fgroup__nrf__drv__twi.html
The examples on the SDK page shows a minimal example:
So i wonder what might be wrong with my attempt?
The text was updated successfully, but these errors were encountered: