You will need a second device that will function as I2C slave. Have you got one? So first you will have to decide who is I2C-master and who is I2C-slave.
Only the master can read and write to/from the slave. There are master/slave examples which you should understand first.
Electrically, the two I2C-lines clock and data need pullup resistors for the interface to function properly.
Although this video is for PSOC 1 the basic principles the same -
Also search youtube for I2C, there are other videos there as well.
In Creator there are examples, on Creator start page link "Find Example projects"
actully I want to display data to LCD via i2c communication.
I need to develope algorithms. what I have to Do ?
1. start I2C
2. send data to LCD
4. LCD _PrintString()
6. Stop I2c
I am trying to make program on psoc creator 3.0. In my next post I will try to write compelete program
No need to stop the I2C, let it run as long as there is power applied.
Give us a link to the LCD datasheet with I2C interface that you want to connect to your PSoC board.
Which board are you using? Give us Cypress part no. or link.
The basic protocol is a start/stop -
Communication via I2C is more complex than with a UART or SPI solution. The signalling must adhere to a certain protocol for the devices on the bus to recognize it as valid I2C communications. Fortunately, most devices take care of all the fiddly details for you, allowing you to concentrate on the data you wish to exchange.
Messages are broken up into two types of frame: an address frame, where the master indicates the slave to which the message is being sent, and one or more data frames, which are 8-bit data messages passed from master to slave or vice versa. Data is placed on the SDA line after SCL goes low, and is sampled after the SCL line goes high. The time between clock edge and data read/write is defined by the devices on the bus and will vary from chip to chip.
To initiate the address frame, the master device leaves SCL high and pulls SDA low. This puts all slave devices on notice that a transmission is about to start. If two master devices wish to take ownership of the bus at one time, whichever device pulls SDA low first wins the race and gains control of the bus. It is possible to issue repeated starts, initiating a new communication sequence without relinquishing control of the bus to other masters; we’ll talk about that later.
The address frame is always first in any new communication sequence. For a 7-bit address, the address is clocked out most significant bit (MSB) first, followed by a R/W bit indicating whether this is a read (1) or write (0) operation.
The 9th bit of the frame is the NACK/ACK bit. This is the case for all frames (data or address). Once the first 8 bits of the frame are sent, the receiving device is given control over SDA. If the receiving device does not pull the SDA line low before the 9th clock pulse, it can be inferred that the receiving device either did not receive the data or did not know how to parse the message. In that case, the exchange halts, and it’s up to the master of the system to decide how to proceed.
After the address frame has been sent, data can begin being transmitted. The master will simply continue generating clock pulses at a regular interval, and the data will be placed on SDA by either the master or the slave, depending on whether the R/W bit indicated a read or write operation. The number of data frames is arbitrary, and most slave devices will auto-increment the internal register, meaning that subsequent reads or writes will come from the next register in line.
Once all the data frames have been sent, the master will generate a stop condition. Stop conditions are defined by a 0->1 (low to high) transition on SDA after a 0->1 transition on SCL, with SCL remaining high. During normal data writing operation, the value on SDA should not change when SCL is high, to avoid false stop conditions.
If your LCD is 44780 compatible controller just use Character LCD. It connects
via 4 pins for data, 3 pins for control.
If the LCD has a I2C interface, then select Character LCD with I2C interface and
place an I2C master component.
Your selected LCD Jhd 16 2A uses an 8-bit wide databus and some control-signals. There is no component to directly connect the LCD to your PSoC, so you will have to program everything yourself which is not an easy job.
What is your I2C interface for? Do you want to build an LCD-module with an I2C interface? What will be the Master??
Your Jhd 16 2A has a 44780 compatible controller in it, so
use Character LCD for the module. It does not have an I2C
interface. It takes 4 bits + 3 control lines to connect to PSOC.
In its component datasheet are the instructions (APIs) to
The above componnet uses one contiguous port to connect. If you
need to spread across multiple ports the connections see Kees
Vead: I sent you a working program that writes to a character LCD a few days ago. LCD_Arduino.bundel01. this program is working and does not need an I2C interface. Why have you not used this program and converted it to the Cy8CKIT-049-4200 that you have? When I researched the data sheet for your display I am not sure that it will work with a 44780 type display but you should try it anyway. It it works fine if it fails then get a 44780 compatable display and you will be in business with a working display!!
I Have done Projects based on LCD. LCD Display is not Problem. I want to use I2C communication. that's why I am trying to interface LCD with I2C
Look at following project sample. I did small change. I placed I2C component.
1. start I2C
2 stop I2C
how to send data on LCD via I2C communication ?
Get an example I2C program from the example programs in Psoc 4 M page and then transfer the I2C data from the example to your program. You can not use the current display on I2C just the data you receive from the I2C device. here is the address http://www.cypress.com/?rID=108008. or this is a good manual for all Psoc types and how to use I2C http://www.cypress.com/?docID=52704. There is a good example in 100 projects in 100 days http://www.element14.com/community/thread/25071/l/psoc-4-pioneer-kit-community-project035-uart-i2c-and-spi-joystick-example But you need a RTC chip to make this app work. If you want to use the I2C to talk to an LCD you need to replace your LCD with another one or use one of these
i2c / SPI character LCD backpack you feed in I2C signal on 2 wires and it provides the drive signals for the LCD. You can find thes backpacks on the internet at various vendors and the are about $10.00 US.
Any data you write to the display can also be written out
over the I2C link. The I2C does not have a clue if it is sending
LCD data or swamp monster counts, data is data.
The I2C slave receiving the data has to be addressed by the
master and then data is sent to it. Examples of this are used in
several of these projects -
PSOC 4 element14.com
As long as you mapped the LCD pins to the correct port
pin ordering you are OK. Rename the PSOC port pins to
correspond to the LCD pin name, makes it easy to keep
Also you have to connect LCD power and ground. And connect contrast pin on LCD to a pot.
Nominally set it to Vdd / 2 then adjust for best display appearance.