EE 345S Real-Time Digital Signal Processing Lab Fall 2007 Lab #2 Generating a Sine Wave Using the Hardware & Software Tools for the TI TMS320C6713 DSP.

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

Chapter 3 Basic Input/Output
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
I/O Unit.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
68HC11 Polling and Interrupts
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
1 Lecture 2: Review of Computer Organization Operating System Spring 2007.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
Communication Lab - Interrupts 1/13 Sequential Programming  Our C++ programs are sequential ( סדרתיים), they start at the first instruction and end at.
Introduction An interrupt is an event which informs the CPU that its service (action) is needed. Sources of interrupts: internal fault (e.g.. divide by.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
Introduction to Interrupts
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
GURSHARAN SINGH TATLA PIN DIAGRAM OF 8085 GURSHARAN SINGH TATLA
EE 445S Real-Time Digital Signal Processing Lab Fall 2011 Lab #2 Generating a Sine Wave Using the Hardware & Software Tools for the TI TMS320C6748 DSP.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
COMP201 Computer Systems Exceptions and Interrupts.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
MICROPROCESSOR INPUT/OUTPUT
EE 445S Real-Time Digital Signal Processing Lab Fall 2013 Lab #2 Generating a Sine Wave Using the Hardware & Software Tools for the TI TMS320C6748 DSP.
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
Microprocessors 1 MCS-51 Interrupts.
Lecture 14 Today’s topics MARIE Architecture Registers Buses
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Chapter 3 Basic Input/Output. Chapter Outline Basic I/O capabilities of computers I/O device interfaces Memory-mapped I/O registers Program-controlled.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Generating Sinusoidal Signals Prof. Brian L. Evans Dept. of Electrical and Computer Engineering The University of Texas at Austin EE 445S Real-Time Digital.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.
ECE 447 Fall 2009 Lecture 7: MSP430 Polling and Interrupts.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Lecture 1: Review of Computer Organization
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Copyright © 2007 by Curt Hill Interrupts How the system responds.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
EE 345S Real-Time Digital Signal Processing Lab Fall 2008 Lab #3 Generating a Sine Wave Using the Hardware & Software Tools for the TI TMS320C6713 DSP.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
MICROPROCESSOR BASED SYSTEM DESIGN
Microprocessor and Assembly Language
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
Interrupts In 8085 and 8086.
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
* * * * * * * 8051 Interrupts Programming.
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
11.1 Interrupt Mechanism, Type, and Priority
X1 & X2 These are also called Crystal Input Pins.
Lecture 9: TI MSP430 Interrupts & Low Power Modes
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
CNET 315 Microprocessor & Assembly Language
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
COMP3221: Microprocessors and Embedded Systems
EE 345S Real-Time Digital Signal Processing Lab Fall 2007
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

EE 345S Real-Time Digital Signal Processing Lab Fall 2007 Lab #2 Generating a Sine Wave Using the Hardware & Software Tools for the TI TMS320C6713 DSP Akshaya Srivatsa

2 Outline DSK initialization TLV320AIC23 Audio Interface Sine Wave Generation  Function Call  Lookup Table  Difference Equation Outputting Methods  Polling  Interrupts  Direct Memory Access (DMA)

3 Profiling To find the number of cycles for execution of code. Requires you to set software breakpoints ONLY.

4 Linker File: dsk6713.cmd Defines the following  Relocation of program code  Autoinitialize all C variables  Chip support libraries  Allocation of FLASH(256kB), SDRAM(16MB) and IRAM(256kB).  Allocation of stack, C I/O functions, global and static variables, interrupts Loading GEL (general extension language) extensions.  Used to initialize CPU in debug mode.

5 AIC23 Control Registers Gives control to modify the inputs and outputs DSK This is for real-time implementation purely between DSK and external measurement devices. Source\shared_codec.c will contain configurations for these resgisters.

6 AIC23 Data Word and Operations Sample on each channel is 16 bit 2’s compliment. Data between DSP and AIC23 interface is sent as 32 bit data.  Upper 16 bits = Left channel  Lower 16 bits = Right Channel  Present in Data Receive Register of McBSP 2 important functions used:  DSK6713_AIC23_read  DSK6713_AIC23_write Present in dsk6713.bsl

7 Sine Wave Generation One-sided discrete-time signal of frequency ω 0 cos(ω 0 n)u[n] One-sided continuous-time signal of frequency ω 0 cos(2πf 0 t)u(t) Using a sample frequency f s such that f s > 2.f 0 Substitute t=nT s =n/f s cos(2π(f 0 /f s )n)u[n] ω 0 =2π(f 0 /f s ) radians/sample

8 Sine Wave Generation Function Call: Use the C library function sin(x) whenever a sine value is needed, approximated as the ratio of 2 10 th order polynomials in x  Computation: 21 multiplications, 21 additions and 1 division  Memory Usage: 22 coefficients and 1 intermediate variable (x) and one constant (2  ) Lookup Table: Pre-compute and store one period of samples, can even store one-half or one-quarter period and use symmetry.  Frequency is ω 0 =2πN/L  L is the period  Interpolate stored values to get result at all frequencies  No computation needed, just memory reads.

9 Sine Wave Generation Difference Equation: Input x[n] and output y[n] (zero IC’s) y[n] = (2 cos  0 ) y[n-1] - y[n-2] + x[n] - (cos  0 ) x[n-1]  Results from z-transform of cos(ω 0 n)u[n]  Computation: 2 multiplications and 3 additions  Memory Usage: 2 coefficients, 2 previous values of y[n] and 1 previous value of x[n]  Drawback is the build-up of error due to feedback

10 Outputting Methods Polling: means constantly monitoring a device, a flag or a register until its value changes.  Poll XRDY (transmit ready) bit of the McBSP0 (Multi- Channel Buffered Serial Port) serial port until TRUE then write to DXR (data transmit register) of the McBSP1. If XRDY is TRUE, function returns the sample and the value 1, If XRDY is FALSE, function returns immediately without sending a sample and return the value 0.

11 Serial Port Transmitter CPU writes a 32-bit word to the DXR. XRDY flag is cleared whenever data is written to DXR. After a word is shifted out of XSR, a transfer of the DXR to the XSR is performed. XRDY flag is set. When XRDY is set, serial port transmitter sends an interrupt request (XINT) to CPU.

12 Serial Port Receiver Bits received serially into RSR. When word is complete it is transferred to RBR. RBR copied to DRR if it is empty. RRDY bit in SPCR is set when RSR is moved to DRR and is cleared when DRR is read. When RRDY is set, McBSP generates a CPU interrupt request (RINT).

13 Outputting Methods Polling: for ( ; ; )// Infinite Loop { x_left = scale*sin(angle_left); x_right = scale*sin(angle_right); // Increment phase angles of sine waves angle_left += delta_left; angle_right += delta_right; // Reduce angles modulo 2 pi so no overflow if (angle_left > 2.0*PI) angle_left -= 2.0*PI; if (angle_right > 2.0*PI) angle_right -= 2.0*PI; WriteSample( x_left, x_right ); } Multiply the sin() by a scale so that it doesn’t become 0 when it’s converted to integer since |sin()|<1 and floats less 1 are converted to 0

14 Outputting Methods Polling: void WriteSample( float left, float right) { Uint32 ileft = (Uint32) left; Uint32 iright = (Uint32)right; Uint32 output; /* Combine ileft and iright into a 32-bit word */ output = (iright << 16) | (ileft & 0x0000ffff); /* DSK6713_AIC23_write polls the Ready flag of the serial port and returns true/false to indicate success. */ while(!DSK6713_AIC23_write(hCodec, output)); } Poll XRDY bit and write output to McBSP0 DXR Combine both samples into a 32-bit word to transmit via McBSP1 Convert float to integer (IMPORTANT)

15 Important Points Know your sampling frequency.  Its in shared_codec.c Do not put a huge value for scaling factor (Keep it less than 15000) Signal frequency must be kept below one half of sampling frequency.

16 Outputting Methods Polling:  Most of the time in the polling method is spent in the infinite loop waiting for the XRDY flag to get set,  DSP is doing nothing,  A more efficient approach is to let DSP run tasks in background (modulating/demodulating, coding/decoding…),  So, serial port will interrupt background tasks when sample is received and needs to be transmitted.

17 Outputting Methods Interrupts: are signals from hardware/software indicating the need for attention or change of execution. C6713 DSP has a vectored priority interrupt controller that can handle 16 different interrupts:  RESET interrupt has highest priority, cannot be masked,  NMI (Non-Maskable Interrupt) has the second highest priority (used to notify DSP of serious hardware errors),  2 reserved maskable interrupts come next,  12 additional maskable interrupts (INT4-INT15) have the lowest priority.

18 Interrupts Interrupt Control Registers Interrupt Source Default Mappings

19 Outputting Methods Conditions for an interrupt to occur:  Global Interrupt Enable bit (bit 0 of Control Status Register) must be set to 1. If GIE=0, no maskable interrupt can occur,  Non-Maskable Interrupt Enable bit (in the Interrupt Enable Register) must be set to 1. If NMIE=0, no maskable interrupt can occur,  Bit corresponding to desired interrupt must be set to 1 in Interrupt Enable Register. When interrupt occurs, corresponding bit in IFR (interrupt flag register) is set to 1. No higher priority interrupt flag should be set to 1 in IER.

20 Outputting Methods When CPU interrupt ‘n’ occurs, program execution jumps to byte offset 32×n in an Interrupt Service Table (IST) which contains 16 Interrupt Service Fetch Packets (ISFP) each containing 8 32-bit instructions. ISFP may contain an entire Interrupt Service Routine (ISR) or may branch to a larger one. IST is relocated during initialization  Base address is held by Interrupt Service Table Pointer(ISTP)

21 Outputting Methods When an interrupt occurs:  DSP sets corresponding interrupt flag in IFR to 1,  If GIE=NMIE=1 and no higher priority interrupts are pending, interrupt is serviced: GIE copied to PGIE (previous global interrupt enable bit) and GIE is cleared, Flag bit in IFR is cleared indicating interrupt is serviced, Return address is put in the Interrupt Return Pointer (IRP), Execution jumps to corresponding ISFP entry, Service routine must save the CPU state and restore it on exit. User defined ISRs syntax  interrupt void your_isr_name(){body}

22 Outputting Methods /* Select McBSP1 transmit int for INT15 */ intr_map(CPU_INT15, ISN_XINT1); /* Hook our ISR to INT15 intr_hook(tx_isr, CPU_INT15); /* Clear old interrupts INTR_CLR_FLAG(CPU_INT15); /* Enable interrupts INTR_ENABLE(CPU_INT_NMI); /* Set INT15 bit in IER INTR_ENABLE(CPU_INT15); /* Turn on enabled ints INTR_GLOBAL_ENABLE(); /*To write out MCBSP_write(DSK6713_AIC23_DATAHANDLE, output);

23 Templates for programs are available online ab2/index.html Lets get started then!!