Temperature Sensor TCN75A Pmod Controller (VHDL)

Logic Home

Code Downloads

Temperature Sensor Pmod Controller (top-level file): pmod_temp_sensor_tcn75a.vhd (11.7 KB)

I2C Master (must also be included in the project): i2c_master.vhd (14.1 KB)


  • VHDL source code of a streamlined interface to Digilent’s PmodTMP3 (Pmod for Microchip’s TCN75A Temperature Sensor)
  • Continually outputs latest temperature data on a parallel interface
  • Handles I2C communication and all data retrieval from the Temperature Sensor Pmod
  • Handles configuration of the temperature sensor’s resolution
  • Configurable system clock rate


This details a VHDL component that handles interfacing to Digilent’s Temperature Sensor TCN75A Pmod, shown in Figure 1. Figure 2 illustrates a typical example of this Temperature Sensor Pmod Controller integrated into a system. As shown, the Temp Sensor Pmod Controller connects to the Pmod ports and executes transactions to configure the temperature sensor and gather data. The data is continually updated and presented on a simple parallel interface which can be connected to user logic or to output ports on the FPGA.


Figure 1. Digilent Temperature Sensor TCN75A Pmod

Figure 2. Example Implementation

Theory of Operation

The Temperature Sensor Pmod Controller consists primarily of a state machine and an I2C Master component.

State Machine

The design uses the state machine depicted in Figure 3 to implement its operation. Upon start-up the component immediately enters the start state. It remains in this state for 100ms to ensure the Pmod has ample time to power-up. It then proceeds to the set_resolution state, where it configures the temperature sensor’s resolution. Once complete, it enters the set_reg_pointer state to set up the temperature sensor for data readings. In the following read_data state, it gathers the most recent temperature data from the Pmod’s temperature sensor. Finally, it outputs the temperature in the output_result state. It then continuously cycles between the read_data and output_result states to keep the temperature data constantly updated. Resetting the component at any time returns it to the start state.

Figure 3. State Diagram

I2C Master

During the set_resolution, set_reg_pointer, and read_data states, the state machine controls an I2C Master component to communicate with the temperature sensor on the Pmod. Documentation for the I2C Master is available here.

Configuring the Temp Sensor Pmod Controller

The Temp Sensor Pmod Controller is configured by setting the generic parameters in the entity.

System Clock Frequency

The generic parameter sys_clk_freq must be set to the frequency of the system clock provided to the Temp Sensor Pmod Controller on its clk port.


The generic parameter resolution defines the resolution (in bits) with which the TCN75A temperature sensor is then configured. Table 1 describes the options and tradeoffs. The default value is 9 bits of resolution. Any invalid resolution setting reverts to 9 bits.

Table 1. Resolution Options


Pmod I2C Address

The Temp Sensor Pmod Controller must have the Pmod’s 7-bit I2C address to communicate. The 4 most significant bits are “1001” and the following 3 bits are set by the Pmod’s jumper blocks JP3, JP2, and JP1, respectively.

The generic parameter temp_sensor_addr must be set to this address. The default value “1001000” corresponds to all 3 jumpers connected to GND.

Port Descriptions

Table 2 describes the Temp Sensor Pmod Controller’s ports.

Table 2. Port Descriptions


This Pmod has an 8-pin connector. Table 3 provides the pinout for this connector. The Temp Sensor Pmod Controller’s ports need to be assigned to the FPGA pins that are routed to this connector as listed. The two rows of the J1 connector are tied together on the Pmod board, so only one side needs to be connected to the FPGA.

Table 3. Temp Sensor Pmod Pinout and Connections to the Temp Sensor Pmod Controller

The Pmod also has several jumpers. JP4 and JP5 must be enabled (i.e. connected) to connect the required I2C pull-up resisters for SCL and SDA. JP6 is not used. JP1, JP2, and JP3 set the I2C address of the Pmod. See the Pmod I2C Address section above for details.


The reset_n input port must have a logic high for the Temperature Sensor Pmod Controller component to operate. A low logic level on this port asynchronously resets the component. During reset, the component aborts the current transaction with the Pmod and clears the temperature data output and the i2c_ack_err output. Once released from reset, the Temperature Sensor Pmod Controller restarts its operation. It reconfigures the temperature sensor and resumes collecting and outputting temperature data.


This Temperature Sensor Pmod Controller is a programmable logic component that interfaces to Digilent’s PmodTMP3 (Temperature Sensor TCN75A Pmod). It handles all communication with this Pmod to configure the Pmod’s temperature sensor and provide a continual stream of updated temperature data on a parallel output.

Additional Information

Microchip TCN75A datasheet (498.7 KB)

Related Topics

I2C Master (VHDL)


Comments, feedback, and questions can be sent to eewiki@digikey.com.