PT8: Multi-standard video encoder IP core

PT13: Very compact microprocessor IP core

PT6: Video Pattern Generator IP core

|
This IP block provides a simple write only controller for the I2C bus, using just 77 logic elements and some memory or latches for the I2C register data. The design requires only a clock and reset and provides SDA and SCL output lines.
To download the controller, click on the zip file icon in the panel on the right and save to disc. Unzip the files in your chosen directory and you are ready to go. The download provides the symbol file, the AHDL (Altera high level description language) file I2C_controller.tdf and an example memory file, I2C_ROM.mif. Verilog versions of the two files can also be downloaded from the panel on the right. To write to an I2C device it is first necessary to send a start condition (a unique condition for the SDA and SCL lines), followed by the unique device address (a 7-bit word), followed by the read/write bit (=0 to write to a device). The device then acknowledges if the address is valid. Next the master then sends a register address (the registers are usually indirectly addressed using an internal address register), and finally the data, starting with the data for the first register, (again most I2C devices auto-increment the register address after each register has been written). Finally when all the registers have been written a stop condition is sent (again a unique state for the SDA and SCL lines) and the bus is freed. The I2C controller consists of two counters, I2C_Byte_count and I2C_sequencer. The former counter addresses the memory where the I2C register values are kept. On reset this counter is set to 0 and addresses location $00 in the memory. The counter value is decoded and if zero this signals a start condition to be performed on the I2C bus. The I2C_sequencer counter then starts and in turn, its values are decoded, each value setting or resetting the SCL and SDA bit according to the requirement. When the I2C sequencer gets to value 9 it stops and the I2C_Byte_count is incremented. The next value read from the memory is the I2C address of the device. Again the I2C_sequencer counter serializes the memory value as well as receiving the acknowledge clock from the device. Note that this simple I2C controller does not check if the acknowledge is valid and sends the information ‘blind’. The next byte is usually the register address value for the I2C device, and the following bytes are the corresponding values for the rest of the registers. When all of the registers of the device have been written to, the decoded I2C_Byte_count counter signals a stop condition to be sent. If there are more devices in the system then the next value can signal another cycle to be initiated and so on until all the devices have had their registers loaded. When the last stop condition is sent the I2C_Byte_count is reset.In the download file we show the I2C values for one condition of the DP1 interface board. There are three I2C devices that require initialization and the data to be downloaded is contained in a file called I2C.ROM.mif (when compiling this software, please ensure that the lpm_ROM definition for this file is pointing at a valid location on your drive). A copy of the file is shown below.
ADDR |
+0 |
+1 |
+2 |
+3 |
+4 |
+5 |
+6 |
+7 |
+8 |
+9 |
+a |
+b |
+c |
+d |
+e |
+f |
00 |
00 |
98 |
01 |
6B |
40 |
60 |
80 |
40 |
00 |
40 |
00 |
40 |
00 |
40 |
00 |
00 |
10 |
80 |
40 |
00 |
20 |
C0 |
7F |
C6 |
0A |
04 |
04 |
0A |
04 |
14 |
33 |
FF |
60 |
20 |
94 |
90 |
07 |
20 |
32 |
14 |
08 |
6F |
10 |
70 |
BF |
02 |
00 |
00 |
00 |
E8 |
30 |
E0 |
00 |
00 |
54 |
00 |
9C |
80 |
20 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
40 |
00 |
00 |
00 |
00 |
00 |
00 |
01 |
00 |
4C |
08 |
00 |
A0 |
80 |
80 |
00 |
00 |
50 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
60 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
70 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
40 |
00 |
00 |
00 |
01 |
00 |
10 |
00 |
08 |
80 |
00 |
1F |
7C |
F0 |
21 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
90 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
A0 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
B0 |
00 |
00 |
00 |
08 |
00 |
C8 |
00 |
00 |
00 |
00 |
FC |
00 |
00 |
00 |
00 |
00 |
C0 |
00 |
00 |
00 |
00 |
00 |
C0 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
D0 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
E0 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
F0 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
00 |
The first location, $00 is the start condition for the AD9981 ADC. The next byte (value $98) is the I2C address for that device. The next byte (value $01) is the register address value for the AD9981 (Register $00 of the AD9981 is a read only register so is not written to), and the following bytes are the corresponding values for the rest of the registers. Location $30 is the last register value for the AD9981, Location $31, signals a stop condition to be sent, location $32 a new start condition to be sent, location $33 is the address of the next I2C device, the ADV7321 ($54), location $34 is the register address ($00) and the following bytes are the data for the ADV7321. Correspondingly location $B0 is the stop condition, $B1 the new start condition, $B2 the register address for the final device, the ADAU1326 ($08) and so on.By editing the memory values the data sent to the I2C devices can be easily changed. Higher address bits to the memory can select other values allowing different data to be sent for differing conditions.
Download I2C controller for Altera FPGAs

I2C bus specification

Verilog I2C files
.jpg)
|
PT4: NTSC/PAL Video decoder IP core

PT2: Video Character Generator IP core

PT29: Program Delivery Code Decoder IP core

|