Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12626 Discussions

Cyclone V LCD / I2C (baremetal) sample for Altera's SoC DevKit

Honored Contributor II

Hi community, 


anybody out there ever programmed the Newhaven LCD on the Altera SoC (Cyclone V) DevKit baremetal


If I didn't miss something Altera's hwlib doesn't provide support for I2C (not to mention support for the LCD). 

As I'm not a linux expert the linux i2c driver isn't very helpfull either. 

If someone could give me a hint where to look for a starting point, that would be really great. 



Thanks a lot for your support!
0 Kudos
1 Reply
Honored Contributor II



I want to give you some hints to get it running. 

it's not very difficult to get it running on a baremetal system. You can still use the hwlib. 

There is a headerfile called alt_i2c.h. This file contains a lot of definitions, needed to implement an i2c driver for your application. 


To write something to the LCD you have to do the following steps: 


first step: you need to write an init-function for the i2c interface. here you have to do the following steps: 



  1. Disable the i2c controller by clearing the enabled bit in the alt_i2c_en register 

  2. set the controller to master mode (register alt_i2c_con_mst_mod

  3. set the speed to standard (the newheaven display only supports 100khz clock rate) (register alt_i2c_con_speed

  4. enable the i2c controller (set enabled bit in the alt_i2c_en register) 




second step: address the slave 


  1. write the address of the slave to the alt_i2c_tar register 




third step: the write function: 


  1. to send data you have to set the ALT_i2c_data_cmd_cmd Register to WRITE 

  2. write the data to the alt_i2c_data_cmd_dat Register 




Now data will be send on the I2C. If you want to implement a full driver you can also check the status register etc. when you send some data... 


Some hints for the newheaven LCD: 



  • Slave address is 0x28 (and not 0x50) 

  • between the commands you send, you need a delay (normally 100µs). 

  • A full list of special commands for the display you can find in the newheaven specification. (Download it from the newheaven website. The LCD is the NHD-0216K3Z) 




I hope it helps you a bit. 


0 Kudos