Hi, i was interfacing oled with nrf52 board. I got some example and modified bit to use it with GCC. But it is now working. Oled not at all starting. oled is 0.96 inch, I2C based 128x64. Vdd = 5v sda = p0.26 scl = p0.27
Here is code github.com/.../
Hi, i was interfacing oled with nrf52 board. I got some example and modified bit to use it with GCC. But it is now working. Oled not at all starting. oled is 0.96 inch, I2C based 128x64. Vdd = 5v sda = p0.26 scl = p0.27
Here is code github.com/.../
Hi,
The problem seems to be that you are using the TWI driver in non-blocking mode, but you do not have any mechanism implemented to make sure that the previous transfer is done before starting a new transfer. If you check the return code of your calls to nrf_drv_twi_tx()
in ssd1306_command()
, you will see that you get a lot of error code 0x11 - NRF_ERROR_BUSY. This leads to that the commands is not sent to the OLED.
A simple fix to this problem is to switch to blocking mode for the TWI instance. This is done by passing NULL
to event_handler argument of nrf_drv_twi_init()
.
Best regards,
Jørgen
I see one more issue in the code. In function ssd1306_display()
, the buffer is sent to the display in a single transfer. From the API documentation of nrf_drv_twi_tx()
, you can see that the input length
is of type uint8_t
, meaning the maximum length of the transfer can be 255 bytes. This is due to the limited EasyDMA buffer in the nRF52 series. You have to split the buffer into multiple transfers of 255 bytes or less. With a resolution of 128x64 pixels, the transfer size will be 128*64/8=1024 bytes. When giving this number to the 8-bit length parameter, the variable will overflow and a lengt of 0 will be used, leading to no data being transferred. This thread might be of help.
I see one more issue in the code. In function ssd1306_display()
, the buffer is sent to the display in a single transfer. From the API documentation of nrf_drv_twi_tx()
, you can see that the input length
is of type uint8_t
, meaning the maximum length of the transfer can be 255 bytes. This is due to the limited EasyDMA buffer in the nRF52 series. You have to split the buffer into multiple transfers of 255 bytes or less. With a resolution of 128x64 pixels, the transfer size will be 128*64/8=1024 bytes. When giving this number to the 8-bit length parameter, the variable will overflow and a lengt of 0 will be used, leading to no data being transferred. This thread might be of help.