Codec. WM8731 Audio Codec

Similar documents
Two Wire Interface (TWI) also commonly called I2C

Introduction to I2C & SPI. Chapter 22

Tutorial for I 2 C Serial Protocol

Sequential Logic - Module 5

1.3inch OLED User Manual

The I2C BUS Interface

SPI 3-Wire Master (VHDL)

VHDL in 1h. Martin Schöberl

Problem Set 10 Solutions

Hello, and welcome to this presentation of the STM32 I²C interface. It covers the main features of this communication interface, which is widely used

MAX 10. Memory Modules

RL78 Serial interfaces

XSV Flash Programming and Virtex Configuration

In our case Dr. Johnson is setting the best practices

McMaster University Embedded Systems. Computer Engineering 4DS4 Lecture 6 Serial Peripherals Amin Vali Feb. 2016

Application Note: AZD025 IQ Switch - ProxSense TM Series I2C Example Code for the IQS222

ENGG3380: Computer Organization and Design Lab4: Buses and Peripheral Devices

Altera s Avalon Communication Fabric

VORAGO VA108x0 I 2 C programming application note

Microcontrollers and Interfacing

Temperature Sensor TMP2 PMOD Part 1

EECE-4740/5740 Advanced VHDL and FPGA Design Lecture 4. Cristinel Ababei Dept. of Electrical and Computer Engr. Marquette University

File: C:\Documents and Settings\Malcolm\My Documents\My FPGA Projects\2007_demo\I

THE INTERNATIONAL JOURNAL OF SCIENCE & TECHNOLEDGE

Timing in synchronous systems

Embedded Systems and Software. Serial Interconnect Buses I 2 C (SMB) and SPI

Lecture 25 March 23, 2012 Introduction to Serial Communications

6.111 Lecture # 8. Topics for Today: (as time permits)

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design

VHDL Testbench. Test Bench Syntax. VHDL Testbench Tutorial 1. Contents

VHDL And Synthesis Review

Counters. Counter Types. Variations. Modulo Gray Code BCD (Decimal) Decade Ring Johnson (twisted ring) LFSR

Today. Comments about assignment Max 1/T (skew = 0) Max clock skew? Comments about assignment 3 ASICs and Programmable logic Others courses

Theory of Operation STOP CONDITION

Freescale Semiconductor, Inc.

I 2 C Slave Controller. I 2 C Master o_timeout_intr

Lecture 7. Standard ICs FPGA (Field Programmable Gate Array) VHDL (Very-high-speed integrated circuits. Hardware Description Language)

The University of Alabama in Huntsville Electrical and Computer Engineering CPE/EE 422/522 Spring 2005 Homework #6 Solution

Each I2C master has 8-deep transmit and receive FIFOs for efficient data handling. SPI to Dual I2C Masters. Registers

I 2 C Communication. Embedded Systems Interfacing. 25 October 2011

34 Series EEPROM Application Note. 1. Introduction. 2. Power supply & power on reset

Universität Dortmund. IO and Peripheral Interfaces

Microcontroller Systems. ELET 3232 Topic 23: The I 2 C Bus

VHDL: Modeling RAM and Register Files. Textbook Chapters: 6.6.1, 8.7, 8.8, 9.5.2, 11.2

Lesson I2C. I²C (Inter-Integrated Circuit) Lab Assignment: I2C Slave Driver

Serial Peripheral Interface. What is it? Basic SPI. Capabilities. Protocol. Pros and Cons. Uses

The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution Spring 2016

or between microcontrollers)

Introduction the Serial Communications Parallel Communications Parallel Communications with Handshaking Serial Communications

How to Implement I 2 C Serial Communication Using Intel MCS-51 Microcontrollers

Schedule. ECE U530 Digital Hardware Synthesis. Rest of Semester. Midterm Question 1a

I 2 C Master Control FSM. I 2 C Bus Control FSM. I 2 C Master Controller

Sequential Statement

The CPU Bus : Structure 0

Summary of FPGA & VHDL

24-bit Audio CODEC. Digital Circuit Lab. TA: Po-Chen Wu

[VARIABLE declaration] BEGIN. sequential statements

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

Lecture 5: Computing Platforms. Asbjørn Djupdal ARM Norway, IDI NTNU 2013 TDT

Introduction to VHDL #1

COVER SHEET: Total: Regrade Info: 5 (14 points) 7 (15 points) Midterm 1 Spring 2012 VERSION 1 UFID:

Audio Controller i. Audio Controller

Control Unit: Binary Multiplier. Arturo Díaz-Pérez Departamento de Computación Laboratorio de Tecnologías de Información CINVESTAV-IPN

Laboratory 5 Communication Interfaces

ECE 459/559 Secure & Trustworthy Computer Hardware Design

I2C Master-Slave Connection

NIOS Character. Last updated 7/16/18

ECE 545 Lecture 8. Data Flow Description of Combinational-Circuit Building Blocks. George Mason University

Real-Time Embedded Systems. CpE-450 Spring 06

COVER SHEET: Total: Regrade Info: 5 (5 points) 2 (8 points) 6 (10 points) 7b (13 points) 7c (13 points) 7d (13 points)

Implementation of MCU Invariant I2C Slave Driver Using Bit Banging

EENG 2910 Project III: Digital System Design. Due: 04/30/2014. Team Members: University of North Texas Department of Electrical Engineering

Design Problem 4 Solutions

Digital Signal Processor for TV

Freescale Semiconductor, I

The EFM32 I2C module allows simple, robust and cost effective communication between integrated circuits using only one data and one clock line.

I2C on the HMC6352 Compass

Hello, and welcome to this presentation of the STM32 Universal Synchronous/Asynchronous Receiver/Transmitter Interface. It covers the main features

Sign here to give permission for your test to be returned in class, where others might see your score:

COVER SHEET: Total: Regrade Info: 7 (6 points) 2 (10 points) 9 (5 points) 8 (12 points) 12 (5 points) 11 (25 points)

CSE 260 Introduction to Digital Logic and Computer Design. Exam 1. Your name 2/13/2014

Field Programmable Gate Array

Interfacing the NM24C16 Serial EEPROM to the microcontroller. Interfacing the NM24C16 Serial EEPROM to the 8031 Microcontroller AN-957

21. TWI Two-Wire Interface

SHIM: A Language for Hardware/Software Integration

Hello, World: A Simple Application for the Field Programmable Port Extender (FPX)

Part 4: VHDL for sequential circuits. Introduction to Modeling and Verification of Digital Systems. Memory elements. Sequential circuits

Parallel Data Transfer. Suppose you need to transfer data from one HCS12 to another. How can you do this?

ECE 545 Lecture 12. Datapath vs. Controller. Structure of a Typical Digital System Data Inputs. Required reading. Design of Controllers

App Note Application Note: Addressing Multiple FPAAs Using a SPI Interface

Problem Set 5 Solutions

The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution March 2, 2006

VHDL for FPGA Design. by : Mohamed Samy

UART. ELEC 418 Advanced Digital Systems Dr. Ron Hayne. Images Courtesy of Cengage Learning

Data Acquisition From Capacitance Sensor AD7746 To Central Monitoring System Using I 2 C Protocol

Nanosistemų programavimo kalbos 5 paskaita. Sekvencinių schemų projektavimas

Microtronix Avalon I 2 C

C8051F700 Serial Peripheral Interface (SPI) Overview

Quartus Counter Example. Last updated 9/6/18

PIC16C7X 11.0 SYNCHRONOUS SERIAL PORT (SSP) MODULE SSP Module Overview. Applicable Devices

Transcription:

Codec WM8731 Audio Codec

Codec Coder / Decoder Audio, Video Compression/decompression signal coding 2 tj

WM8731 3 tj

WM8731 Data Path Basic Connection 4 tj

WM8731 Data Path Basic Timing 5 tj

WM8731 Data Path 16 to 32 bit data Left justified mode 6 tj

WM8731 - Control I2C control interface 7 tj

WM8731 - Control 16 bit word (7 addr, 9 data) 8 tj

Two Wire Interface Overview 8 bit synchronous shift register used to communicate externally 9 bit total communication packet uni-directional Most often used to communicate with peripherals displays, sensors, converters Supports multiple masters and multiple slaves 4 modes of operation Master Receive Master Transmit Slave Receive Slave Transmit 9 tj

Two Wire Interface Overview Open drain configuration outputs only pull down pull up resistors or current sources pull up 10 tj

Two Wire Interface TWI Timing SDA data line SCL clock line Data must be valid during the entire positive clock cycle time Note: data changes occur during SCL low 11 tj

Two Wire Interface TWI Timing Special timing requirements for start transmission stop transmission repeated start transition master does not relinquish the bus in this mode 12 tj

Two Wire Interface TWI Timing Addressing Indicate which slave to transmit to or receive from by first transmitting the address of the desired device Often this value is hardwired via external pins on the slave device 7 bits for each address 13 tj

Two Wire Interface TWI Timing R/W bit indicates a read or write operation is to follow Read is active high ACK The master drives the data bus from start through the R/W bit and then releases the bus The slave then pulls down the bus in the last clock cycle to indicate a completed transmission 14 tj

Two Wire Interface TWI Timing ACK cont d If the master fails to see the slave pull down the bus in the 9 th clock cycle (NACK) Transmission failed Some sort of error action is required 15 tj

Two Wire Interface TWI Timing Data packet After getting an ACK on the address data can be sent 8 bits of data 1 bit for a data ACK This can be repeated many times 16 tj

Control programming I2C interface 1st transmission Device address, R/W 2 nd transmission Register address + Data bit 8 3 rd transmission Data bits 7-0 17 tj

Control programming src: Chu 18 tj

Control programming src: Chu 19 tj

Control programming tristate bidirectional ¼ bit resolution clk 24 bit data register 1 bit 100Kbit/s Buffer SDA SCL 50MHz Counter Control # bits # bytes 20 tj

Control programming CLK Reset Din(23:0) wr_i2c I2C Block sclk sdat Idle fail done 21 tj

Control programming Chu uses the pullup for SDAT = 1 i2c_sdat <= Z when sdat_reg = 1 else 0 ; 22 tj

library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity i2c is port ( clk, reset: in std_logic; din: in std_logic_vector(23 downto 0); wr_i2c: in std_logic; i2c_sclk: out std_logic; i2c_sdat: inout std_logic; i2c_idle, i2c_fail: out std_logic; i2c_done_tick: out std_logic ); end i2c; architecture arch of i2c is constant HALF: integer := 249; -- 10us/20ns/2 = 250 constant QUTR: integer := 125; -- 10us/20ns/4 = 125 constant C_WIDTH: integer := 8; type statetype is ( idle, start, scl_begin, data1, data2, data3, ack1, ack2, ack3, scl_end, stop, turn); signal state_reg, state_next: statetype; signal c_reg,c_next: unsigned(c_width-1 downto 0); signal data_reg, data_next: std_logic_vector(23 downto 0); signal bit_reg, bit_next: unsigned(2 downto 0); signal byte_reg, byte_next: unsigned(1 downto 0); signal sdat_out, sclk_out: std_logic; signal sdat_reg, sclk_reg: std_logic; signal ack_reg, ack_next: std_logic; begin -- ========================================================= ======== -- output -- ========================================================= ======== -- buffer for sda and scl lines process (clk, reset) begin if reset='1' then sdat_reg <= '1'; sclk_reg <= '1'; elsif (clk'event and clk='1') then sdat_reg <= sdat_out; sclk_reg <= sclk_out; end process; -- only master drives scl line i2c_sclk <= sclk_reg; -- i2c_sdat are with pull-up resistors -- and becomes high when not driven i2c_sdat <= 'Z' when sdat_reg='1' else '0'; -- codac fails to acknowledge properly i2c_fail <= '1' when ack_reg='1' else '0'; 23 tj

-- -- next-state logic ========================================================= process(state_reg,bit_reg,byte_reg,data_reg,c_reg,ack_reg, ======== din,wr_i2c,i2c_sdat) -- fsmd for transmitting three bytes begin -- state_next <= state_reg; ========================================================= sclk_out <= '1'; ======== sdat_out <= '1'; -- registers c_next <= c_reg + 1; -- timer counts continuouisely process (clk, reset) bit_next <= bit_reg; begin byte_next <= byte_reg; if reset='1' then data_next <= data_reg; state_reg <= idle; ack_next <= ack_reg; c_reg <= (others=>'0'); i2c_done_tick <='0'; bit_reg <= (others=>'0'); i2c_idle <='0'; byte_reg <= (others=>'0'); case state_reg is data_reg <= (others=>'0'); when idle => ack_reg <= '1'; i2c_idle <= '1'; elsif (clk'event and clk='1') then if wr_i2c='1' then state_reg <= state_next; data_next <= din; c_reg <= c_next; bit_next <= "000"; bit_reg <= bit_next; byte_next <="00"; byte_reg <= byte_next; c_next <= (others=>'0'); data_reg <= data_next; state_next <= start; ack_reg <= ack_next; when start => -- start condition end process; sdat_out <= '0'; if c_reg=half then c_next <= (others=>'0'); state_next <= scl_begin; 24 tj

when scl_begin => -- 1st half of scl=0 sclk_out <= '0'; if c_reg=qutr then c_next <= (others=>'0'); state_next <= data1; when data1 => sdat_out <= data_reg(23); sclk_out <= '0'; if c_reg=qutr then c_next <= (others=>'0'); state_next <= data2; when data2 => sdat_out <= data_reg(23); if c_reg=half then c_next <= (others=>'0'); state_next <= data3; when data3 => sdat_out <= data_reg(23); sclk_out <= '0'; if c_reg=qutr then c_next <= (others=>'0'); if bit_reg=7 then -- done with 8 bits state_next <= ack1; else data_next <= data_reg(22 downto 0) & '0'; bit_next <= bit_reg + 1; state_next <= data1; when ack1 => sclk_out <= '0'; if c_reg=qutr then c_next <= (others=>'0'); state_next <= ack2; when ack2 => if c_reg=half then c_next <= (others=>'0'); state_next <= ack3; ack_next <= i2c_sdat; -- read ack from slave when ack3 => sclk_out <= '0'; if c_reg=qutr then c_next <= (others=>'0'); if ack_reg = '1' then -- slave fails to ack state_next <= scl_end; else if byte_reg=2 then -- done with 3 bytes state_next <= scl_end; else bit_next <= "000"; byte_next <= byte_reg + 1; data_next <= data_reg(22 downto 0) & '0'; state_next <= data1; 25 tj

when scl_end => -- 2nd half of scl=0 sclk_out <= '0'; sdat_out <= '0'; if c_reg=qutr then c_next <= (others=>'0'); state_next <= stop; when stop => -- stop condition sdat_out <= '0'; if c_reg=half then c_next <= (others=>'0'); state_next <= turn; when turn => -- turnaround time if c_reg=half then state_next <= idle; i2c_done_tick <= '1'; end case; end process; end arch; 26 tj