Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
151 views

Beginning FPGA Programming - Partie57

This document discusses using an ADT7420 temperature sensor and an I2C slave IP to simulate temperature sensor readings. It describes downloading an I2C slave IP from GitHub to simulate the temperature sensor interface. It also details configuring an Altera PLL IP to generate a 29.5 MHz clock needed for fast UART communication. Key steps include setting the PLL input clock to 50 MHz, unchecking asynchronous reset, and specifying an output clock of 29.5 MHz.

Uploaded by

ali alilou
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views

Beginning FPGA Programming - Partie57

This document discusses using an ADT7420 temperature sensor and an I2C slave IP to simulate temperature sensor readings. It describes downloading an I2C slave IP from GitHub to simulate the temperature sensor interface. It also details configuring an Altera PLL IP to generate a 29.5 MHz clock needed for fast UART communication. Key steps include setting the PLL input clock to 50 MHz, unchecking asynchronous reset, and specifying an output clock of 29.5 MHz.

Uploaded by

ali alilou
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Chapter 13 ■ Temperature Sensors: Is It Hot in Here, or Is It Just Me?

Figure 13-12.  Temperature sensor block diagram

The most important thing is that it provides an I2C slave interface and it is connected to the FPGA pins with
two pull-up resistors. The I2C interfaces for external control and sends out the temperature data. That is all we
need to get the temperature data and control the sensor. Figure 13-13 shows the sensor registers. We are going to
use registers 0x00, 0x01, 0x03, 0x08, and 0x2F. Figure 13-14 shows the binary data mapping to temperature.

Figure 13-13.  Temperature sensor register map

277
Chapter 13 ■ Temperature Sensors: Is It Hot in Here, or Is It Just Me?

Figure 13-14.  13 bits of data map to temperature in degrees C

We will use the quick guide from the ADT7420 datasheet to get the data through I2C and send it back to
the PC.
The following steps are based on the quick guide for reading temperatures from the ADT7420:
1.
After powering up the ADT7420, verify the setup by reading the device ID from
the address 0x0B. It should be 0xCB.
2.
Write to configuration register address 0x03 with value 0x80. This will set up the
ADC and provide 13-bit data.
3.
Read the temperature value MSB register from address 0x00 and read the
LSB register from address 0x01. This should provide us with the temperature
measurement. If the data read-back is 0x190, then the temperature is 25°C.
These three steps will be translated to a UART command and sent from the PC to the BeMicro Max 10
board. Since the ADT7420 temperature sensor works as an I2C slave/receiver device, we will use the I2C
master to send the commands to the sensor. In the next section we will download another IP which is also
an I2C slave from another web site. It is only used for simulation. We need the I2C slave IP to simulate the
temperature sensor.

13.3.4 I2C Slave
For simulation, we need to have an I2C Slave to work and look like the ADC I2C interface. We found an
easy-to-use one from GitHub. It is really surprising to us that GitHub hosted VHDL (VHSIC (very high
speed integrated circuit) Hardware Description Language) code hosted on it! The following note shows the
download link. We need to use a specific revision from GitHub. Don’t download the master version.

■■Note  I2C slave link: https://github.com/oetr/FPGA-I2C-Slave/blob/


bd7833a8cb663f2d9d756be50567fd613c919aa8/I2C_slave.vhd.

We only need one file—I2C_slave.vhd—from GitHub. Figure 13-15 shows the web site screenshot and
the port list of the I2C slave module.

278
Chapter 13 ■ Temperature Sensors: Is It Hot in Here, or Is It Just Me?

Figure 13-15.  Download I2C slave IP from GitHub

The port list in Figure 13-16 has scl and sda. They form the I2C interface and the user interface as a
simple read/write register interface. Figure 13-16 shows the port list of the I2C slave module. We will set the
SLAVE_ADDR to 0x48 in the simulation which is the exact address used by ADT7420. The user interface section
shows the read or write operation from the master with the data in or out.

Figure 13-16.  I2C Slave IP VHDL port list

279
Chapter 13 ■ Temperature Sensors: Is It Hot in Here, or Is It Just Me?

13.4 FPGA IP—Altera PLL IP


This time we only need a simple PLL which is able to generate 29.5 MHz. It is used to generate the UART
921600 bps. This bps sounds too large for normal UART, but we are using a special UART which can run that
fast. The locked output is used to generate reset to the system. Figure 13-17 shows the RTL diagram of the PLL.

Figure 13-17.  Altera PLL block diagram

Give the PLL the name pll_29p5M (see Figure 13-18) and select VHDL. In the MegaWizard of the PLL
(Figure 13-19), execute the following steps
1.
In the first tab (General/Mode), set the inclk0 equal to 50 MHz (Figure 13-19).
2.
In the first tab (Inputs/Lock), uncheck the Create an "areset" input to
asynchronously reset the PLL (Figure 13-20).
3.
In the third tab (clk c0), enter the output clock frequency request to 29.5 MHz
(Figure 13-21).
4.
Click Finish two times; then you should have your PLL IP.

Figure 13-18.  Name the PLL pll_29p5M.vhd

280
Chapter 13 ■ Temperature Sensors: Is It Hot in Here, or Is It Just Me?

Figure 13-19.  Set the inclk0 input to 50.00 MHz

Figure 13-20.  Uncheck the Create an "areset" input to asynchronously reset the PLL

281

You might also like