Chapter 6 Multi-channel Buffered Serial Port (McBSP)

Slides:



Advertisements
Similar presentations
Copyright © 2003 Texas Instruments. All rights reserved.
Advertisements

INPUT-OUTPUT ORGANIZATION
Chapter 5 Enhanced Direct Memory Access (EDMA). Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 5, Slide 2 Learning Objectives.
PROGRAMMABLE PERIPHERAL INTERFACE -8255
Chapter 6 Multi-channel Buffered Serial Port (McBSP)
0 - 1 © 2007 Texas Instruments Inc, Content developed in partnership with Tel-Aviv University From MATLAB ® and Simulink ® to Real Time with TI DSPs Audio.
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
NS Training Hardware. System Controller Module.
INPUT-OUTPUT ORGANIZATION
Serial Peripheral Interface Module MTT M SERIAL PERIPHERAL INTERFACE (SPI)
Multichannel Serial Port Interface (McSPI)
DSP C5000 Chapter 9 Understanding and Programming the Multi-channel Buffered Serial Port (McBSP) Copyright © 2003 Texas Instruments. All rights reserved.
Volume. 1-the idea of the program is to increase, decrease the volume. 2-the program does the following: A-PF8:decrease the volume B-Pf9:increase the.
The 8253 Programmable Interval Timer
Universal Synchronous/Asynchronous Receiver/Transmitter (USART)
1-1 Embedded Network Interface (ENI) API Concepts Shared RAM vs. FIFO modes ENI API’s.
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
McBSP Copyright © 2012 Texas Instruments. All rights reserved. Technical Training Organization T TO C6657 Workshop.
Top Level View of Computer Function and Interconnection.
Digital Logic Design.
EDMA3, QDMA and IDMA for the Keystone Platform
RX Serial Peripheral Interface (RSPI)
NS Training Hardware Traffic Flow Note: Traffic direction in the 1284 is classified as either forward or reverse. The forward direction is.
Using the McBSP Chapter 6 C6000 Integration Workshop Copyright © 2005 Texas Instruments. All rights reserved. Technical Training Organization T TO.
Chapter 6 Multi-channel Buffered Serial Port (McBSP)
DSP C 5000 Chapter 8 Direct Memory Access (DMA) Copyright © 2003 Texas Instruments. All rights reserved.
SINE8I PROGRAM. AICSEC.word 162Ch,1h,4892h,67h ;Fs = 8 kHz This instruction sets the sampling frequency, fs, at 8 kHz.
8255:Programmable Peripheral Interface
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.
Tiva C TM4C123GH6PM UART Embedded Systems ECE 4437 Fall 2015 Team 2:
 The LPC2xxx devices currently have two on- chip UARTS.  Except UART1 has additional modem support.
The HCS12 SCI Subsystem A HCS12 device may have one or two serial communication interface. These two SCI interfaces are referred to as SCI0 and SCI1. The.
Class Exercise 1B.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Tutorial Introduction
Programming the I/O Hardware
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.
UNIT – Microcontroller.
Chapter 4 C6000 Integration Workshop
8086 Microprocessor.
UQC113S2 – Embedded Systems
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
Dr. Michael Nasief Lecture 2
8085 Microprocessor Architecture
E3165 DIGITAL ELECTRONIC SYSTEM
CS703 - Advanced Operating Systems
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
Introduction to Microprocessors and Microcontrollers
Programming the I/O Hardware
SPI Protocol and DAC Interfacing
8255.
Serial Communication Interface: Using 8251
Parallel communication interface 8255
SPI Protocol and DAC Interfacing
EE 445S Real-Time Digital Signal Processing Lab Fall 2013
Chapter 5 Enhanced Direct Memory Access (EDMA)
8085 Microprocessor Architecture
Channel Sorting with the EDMA
8259 Programmable Interrupt Controller
Digital Fundamentals Floyd Chapter 1 Tenth Edition
Programmable Data Communication Blocks
Professors: Eng. Diego Barral Eng. Mariano Llamedo Soria Julian Bruno
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
Programmable Interrupt Controller (PIC)
William Stallings Computer Organization and Architecture 7th Edition
EE 345S Real-Time Digital Signal Processing Lab Fall 2007
Jazan University, Jazan KSA
ADSP 21065L.
The Programmable Peripheral Interface (8255A)
Presentation transcript:

Chapter 6 Multi-channel Buffered Serial Port (McBSP)

Objectives Definition of Terms: Bit, word or channel, frame and phase. Understand basic serial port operation. Understand clock generation. Pin polarity. Serial port interrupts. Describe multi-channel operation. Programming the serial port.

Basic Definitions: Bits, Words ? CLK FS Data Data a1 a0 b7 b6 b5 b4 b3 b2 b1 b0 Word Bit “Bit” - one data bit per SP clock period. SP Ctrl (SPCR) Rcv Ctrl (RCR) Xmt Ctrl (XCR) Rate (SRGR) Pin Ctrl (PCR) Serial Port “Word” or “channel” contains #bits specified by WDLEN1 (8, 12, 16, 20, 24, 32). RWDLEN1 5 7 XWDLEN1

Basic Definitions: Frame? FS w0 w1 w2 w3 w4 w5 w6 w7 Frame Word Data “Frame” - contains one or multiple words. FRLEN1 specifies #words per frame (1-128). Serial Port RFRLEN1 8 14 XFRLEN1 7 5 SP Ctrl (SPCR) RWDLEN1 Rcv Ctrl (RCR) Xmt Ctrl (XCR) 7 5 Rate (SRGR) XWDLEN1 Pin Ctrl (PCR)

Basic Definitions - Phase FS Frame Phase 1 Phase 2 Data A B 3 2 1 Note: dual-phase used in Audio Codec97 (AC97) Std Each FRAME can contain only 1 or 2 PHASES (PHASE). Each PHASE can contain different #bits (WDLEN1/2) and #words (FRLEN1/2) . Phase 2 Phase 1 Serial Port PHASE 31 RFRLEN2 RWDLEN2 23 24 21 30 XFRLEN2 XWDLEN2 14 8 7 5 SP Ctrl (SPCR) RFRLEN1 RWDLEN1 Rcv Ctrl (RCR) Xmt Ctrl (XCR) 14 8 7 5 Rate (SRGR) XFRLEN1 XWDLEN1 Pin Ctrl (PCR)

Basic Definitions - Phase FS 8 16 Data 1 2 3 A B Phase 1 Phase 2 Frame Each FRAME can contain 1 or 2 PHASES (PHASE). Each PHASE can contain different #bits (WDLEN1/2) and #words (FRLEN1/2) . From above example some of the bit fields of RCR and XCR can be initialised as shown below. Phase 2 Phase 1 Serial Port 31 30 24 23 21 14 8 7 5 SP Ctrl (SPCR) PHASE RFRLEN2 RWDLEN2 RFRLEN1 RWDLEN1 Rcv Ctrl (RCR) 1 0001 010 0010 000 Xmt Ctrl (XCR) 31 30 24 23 21 14 8 7 5 Rate (SRGR) PHASE XFRLEN2 XWDLEN2 XFRLEN1 XWDLEN1 Pin Ctrl (PCR)

Definitions - Review CLK Word 1 Word 2 Word 3 FS Phase 1 Phase 2 b1 b2 CLK Word 1 Word 2 Word 3 FS Phase 1 Phase 2 Phase 1 Phase 2 Frame 1 Frame 2 Serial Port RFRLEN1 RWDLEN1 5 8 14 7 XFRLEN1 XWDLEN1 RFRLEN2 RWDLEN2 23 24 21 30 XFRLEN2 XWDLEN2 31 PHASE SP Ctrl (SPCR) Rcv Ctrl (RCR) Xmt Ctrl (XCR) Rate (SRGR) Pin Ctrl (PCR)

Objectives Definition of Terms: Bit, word or channel, frame and phase. Understand basic serial port operation. Understand clock generation. Pin polarity. Serial port interrupts. Describe multi-channel operation. Programming the serial port.

McBSP Block Diagram (Read) CPU DMA P e r i p h e r a l B u s RINT REVT R B D 32 DR CLKR FSR RSR

McBSP Block Diagram (Write) CPU DMA RINT XEVT XINT P e r i p h e r a l B u s DR CLKR FSR RSR R B D R 32 DX XSR D X R CLKX REVT FSX

McBSP Block Diagram (Configuration) Multi-Channel Buffered Serial Port (McBSP) CPU DRR P e r i p h B u s DR RSR RBR DX XSR DXR CLKR Serial Port Control Logic CLKX DMA RCR ? FSR SPCR XCR ? FSX Peripheral Bus

Serial Port - Basic Operation Multi-Channel Buffered Serial Port (McBSP) CPU DMA DRR P e r i p h B u s DR RSR RBR DX CLKX FSX XSR DXR CLKR Peripheral Bus Serial Port Control Logic SPCR RCR XCR PCR SRGR FSR “TRANSMIT” “RECEIVE”

McBSP Registers (1) Receive Transmit Control RSR Receive Shift Reg RBR Receive Buffer Reg DRR Data Receive Reg Receive XSR Transmit Shift Reg DXR Data Transmit Reg Transmit SPCR Serial Port Control Reg RCR Receive Control Reg XCR Transmit Control Reg Control

Objectives Definition of Terms: Bit, word or channel, frame and phase. Understand basic serial port operation. Understand clock generation. Pin polarity. Serial port interrupts. Describe multi-channel operation. Programming the serial port.

Configure CLK and FS as inputs or outputs Multi-Channel Buffered Serial Port (McBSP) CLKR Serial Port Control Logic CLKX RCR SRGR FSR SPCR FSX XCR PCR FSR, FSX, CLKR and CLKX can be configured either as inputs or outputs, depending on the application.

Configure CLK and FS as inputs or outputs Multi-Channel Buffered Serial Port (McBSP) CLKR Serial Port Control Logic CLKX RCR SRGR FSR SPCR FSX XCR PCR CLK/FS Mode 0: Input 1: Output SP Ctrl (SPCR) Rcv Ctrl (RCR) Xmt Ctrl (XCR) Rate (SRGR) Pin Ctrl (PCR) Serial Port 11 10 9 8 FSXM FSRM CLKXM CLKRM

Generating CLK and FS as output FSR FSX CLKR CLKX CLK/FS Mode 0: Input 1: Output SP Ctrl (SPCR) Rcv Ctrl (RCR) Xmt Ctrl (XCR) Rate (SRGR) Pin Ctrl (PCR) Serial Port CLKRM FSRM 10 FSXM 11 CLKXM 8 9

Generating the CLK as output Sample Rate Generator (SRGR) CLKOUT1 CLKS CLKGDV CLKG FSR FSX CLKR CLKX CLKSM CLKSM - selects clock src (CLKOUT1 or CLKS) CLKGDV - divide down (1-255) CLKG = (input clock) / (1 + CLKGDV) Max transfer rate = CLKG = 150 MHz/2 = 75 Mb/s Serial Port SP Ctrl (SPCR) Rcv Ctrl (RCR) Xmt Ctrl (XCR) CLKSM 29 CLKGDV 7 Rate (SRGR) Pin Ctrl (PCR)

Generating the FS as output ‘C6000 Sample Rate Generator (SRGR) CLKSM CLKOUT1 CLKS CLKGDV FSR FSX CLKR CLKX FPER FSG CLKG FSGM: 0 - FS gen’d on every DXR XSR copy 1 - FS gen’d by FSG FPER: frame sync period (12 bits) Serial Port SP Ctrl (SPCR) FWID: frame sync pulse width (8 bits) Rcv Ctrl (RCR) Xmt Ctrl (XCR) CLKSM 29 FSGM 28 27 16 FWID 8 15 7 Rate (SRGR) FPER CLKGDV Pin Ctrl (PCR)

McBSP Registers (2) Receive Transmit Control RSR Receive Shift Reg RBR Receive Buffer Reg DRR Data Receive Reg Receive XSR Transmit Shift Reg DXR Data Transmit Reg Transmit SPCR Serial Port Control Reg RCR Receive Control Reg XCR Transmit Control Reg SRGR Sample Rate Generator Control

Objectives Definition of Terms: Bit, word or channel, frame and phase. Understand basic serial port operation. Understand clock generation. Pin polarity. Serial port interrupts. Describe multi-channel operation. Programming the serial port.

Configure CLK and FS pin polarity Multi-Channel Buffered Serial Port (McBSP) CLKR Serial Port Control Logic CLKX RCR SRGR FSR SPCR FSX XCR PCR CLK/FS Polarity 0: Falling edge 1: Rising Edge SP Ctrl (SPCR) Rcv Ctrl (RCR) Xmt Ctrl (XCR) Rate (SRGR) Pin Ctrl (PCR) Serial Port 3 2 1 FSX1 FSRP CLKXP CLKRP

Objectives Definition of Terms: Bit, word or channel, frame and phase. Understand basic serial port operation. Understand clock generation. Pin polarity. Serial port status and interrupts. Describe multi-channel operation. Programming the serial port.

RRDY/XRDY Status and Interrupts RRDY/XRDY displays the “status” of the read and transmit ports: 0: not ready. 1: ready to read/write. RBR DRR CPU RINT XINT RRDY=1 “Ready to Read” EDMA Sync There are 3 methods for detecting if data is ready: Poll SPCR bits via s/w. Config CPU ints (RINT/XINT). Program DMA sync events. XSR DXR XRDY=1 “Ready to Write” Serial Port SP Ctrl (SPCR) XRDY 17 RRDY 1 Rcv Ctrl (RCR) Xmt Ctrl (XCR) Rate (SRGR) Pin Ctrl (PCR)

Other sources of Interrupts (R/XINT) RRDY (RINTM=00B) End of Block (RCV) (RINTM=01) New FSR (frame begin) (RINTM=10b) Receive Sync Error (RINTM=11b) XRDY (RINTM=00b) End of Block (XMT) (RINTM=01b) New FSX (frame begin) (RINTM=10b) Transmit Sync Error (RINTM=11b) “Trigger Event” CPU RINT XINT Serial Port SP Ctrl (SPCR) XINTM 20 21 RINTM 4 5 17 1 Rcv Ctrl (RCR) XRDY RRDY Xmt Ctrl (XCR) Rate (SRGR) Pin Ctrl (PCR)

Objectives Definition of Terms: Bit, word or channel, frame and phase. Understand basic serial port operation. Understand clock generation. Pin polarity. Serial port status and interrupts. Describe multi-channel operation. Programming the serial port.

Multi-Channel operation DR/X Ch0 Ch1 . . . Ch31 Ch0 Ch1 . . . Ch31 FSR/X How do you enable/disable each channel?

Multi-Channel operation DR/X Ch0 Ch1 . . . Ch31 Ch0 Ch1 . . . Ch31 FSR/X You can enable or disable any channel. RCER/XCER Enable Bits Enable [1] Disable [0] 31 Master (MCR) Rcv En (RCER) Xmt En (XCER) Multi-Channel RCER … 1 1 1 31 XCER

Multi-channel example F r a m e 4 3 2 1 Frame 3 1 4 3 2 Frame 2 1 Frame 1 4 3 2 3 1 3 1 M c B S P Memory Allows multiple channels (words) to be independently selected for transmit and receive. 1 3 .

Multi-channel and EDMA combination used for channel sorting Memory 4 3 2 1 Frame 3 . Frame 1 Frame 2 F r a m e M c B S P E D A EDMA’s can sort each channel into separate buffers!

EDMA Channel Sorting 4 3 2 1 . Memory Frame 3 Frame 1 Frame 2 F r a m B S P E D A EDMA’s flexible (indexed) addressing allows it to sort each channel into separate buffers! How do you select channels? ...

Enable/Disable Channels RCER / XCER registers allow you to enable or disable only 32-channels. So how does the C6000 supports 128 channels? 31 RCER XCER 1 … Master (MCR) Rcv En (RCER) Xmt En (XCER) Multi-Channel

128 Channels! 0-15 16-31 32-47 48-63 64-79 80-95 96-111 112-127 Channels A B To be able to support 128 channels the following applies: Channels are broken into BLOCK’s (16 contiguous channels). Up to 32 channels (2 BLOCK’s) can be enabled at any one time. Channels are enabled via _CER registers and _BLK bits in MCR. After 16 channels, McBSP issues END_OF_BLOCK interrupt. CPU ISR re-programs RCER (or XCER) for channels 32-47 and so on. Interrupt A15-0 B15-0 15 16 Master (MCR) Rcv En (RCER) Xmt En (XCER) Multi-Channel 31 RCER XCER

McBSP Registers (3) Receive Transmit Control RSR Receive Shift Reg RBR Receive Buffer Reg DRR Data Receive Reg Receive XSR Transmit Shift Reg DXR Data Transmit Reg Transmit SPCR Serial Port Control Reg RCR Receive Control Reg XCR Transmit Control Reg SRGR Sample Rate Generator PCR Pin Control Reg Control MCR Multi-Channel Ctrl Reg RCER Rcv Channel Enable Reg XCER Xmit Channel Enable Reg

Objectives Definition of Terms: Bit, word or channel, frame and phase. Understand basic serial port operation. Understand clock generation. Pin polarity. Serial port status and interrupts. Describe multi-channel operation. Programming the serial port.

Programming the Serial Port There are three methods available for programming the serial port: 1. Writing directly to the serial port registers. 2. Using the Chip Support Library (CSL). 3. Graphically using the DSP/BIOS GUI configuration tool.

Programming the Serial Port - Direct (A) Writing directly to the serial port registers: Although this method is straight forward, it relies on a good understanding of the serial port functionality. This method can be tedious and is prone to errors. #include <c6211dsk.h> void mcbsp0_init() { *(unsigned volatile int *)McBSP0_SPCR = 0; *(unsigned volatile int *)McBSP0_PCR = 0; *(unsigned volatile int *)McBSP0_RCR = 0x10040; *(unsigned volatile int *)McBSP0_XCR = 0x10040; *(unsigned volatile int *)McBSP0_DXR = 0; *(unsigned volatile int *)McBSP0_SPCR = 0x12001; }

Programming the Serial Port - CSL (1/4) (B) Using the Chip Support Library: The CSL provides a C language interface for configuring and controlling the on-chip peripherals, in this case the Serial Ports. The library is modular with each module corresponding to a specific peripheral. This has the advantage of reducing the code size. Some modules rely on other modules also being included, for example the IRQ module is required when using the EDMA module.

Programming the Serial Port - CSL (1/4) CSL programming procedure: (1) Create handles for the serial ports: (2) Open the serial port: MCBSP_Handle hMcbsp; hMcbsp = MCBSP_open(MCBSP_DEV1, MCBSP_OPEN_RESET);

Programming the Serial Port - CSL (2/4) CSL programming procedure: (3) Create a configuration structure for serial port: \Links\McBSP_Config_Struct.pdf

Programming the Serial Port - CSL (3/4) CSL programming procedure (cont): (4) Configure the serial port: (5) Close the Serial Port after use: MCBSP_config(hMcbsp,&ConfigLoopback); MCBSP_close(hMcbsp);

Programming the Serial Port - CSL (4/4) Practical example: Project name: mcbsp_dynamiccfg.pjt Location: \Code\Chapter 06 - McBSP\Dynamic_CSL_Config\

Programming the Serial Port using the DSP/BIOS GUI (C) DSP/BIOS GUI Interface: With this method the configuration structure is created graphically and the setup code is generated automatically.

Programming the Serial Port using the DSP/BIOS GUI Procedure: (1) Create a configuration using the MCBSP Configuration manager (eg. mcbspCfg0).

Programming the Serial Port using the DSP/BIOS GUI Procedure: (2) Right click and select “Properties”, see the figure below, and then select “Advanced” and fill all parameters as shown below:

Programming the Serial Port using the DSP/BIOS GUI Procedure: (3) Select the serial port you would like to use from the MCBSP Resource manager (eg. Mcbsp_Port1). Right click and select properties. Select the mcbspCfg0 configuration just created.

Programming the Serial Port using the DSP/BIOS GUI Procedure: (4) A file is then generated that contains the configuration code. The file generated for this example is shown on the next slide.

Programming the Serial Port using the DSP/BIOS GUI /* Do *not* directly modify this file. It was */ /* generated by the Configuration Tool; any */ /* changes risk being overwritten. */ /* INPUT mcbsp1.cdb */ /* Include Header File */ #include "mcbsp1cfg.h" /* Config Structures */ MCBSP_Config mcbspCfg0 = { 0x00008000, /* Serial Port Control Reg. (SPCR) */ 0x000000A0, /* Receiver Control Reg. (RCR) */ 0x000000A0, /* Transmitter Control Reg. (XCR) */ 0x203F1F0F, /* Sample-Rate Generator Reg. (SRGR) */ 0x00000000, /* Multichannel Control Reg. (MCR) */ 0x00000000, /* Receiver Channel Enable(RCER) */ 0x00000000, /* Transmitter Channel Enable(XCER) */ 0x00000A00 /* Pin Control Reg. (PCR) */ }; /* Handles */ MCBSP_Handle hMcbsp1; /* * ======== CSL_cfgInit() ======== */ void CSL_cfgInit() { hMcbsp1 = MCBSP_open(MCBSP_DEV1, MCBSP_OPEN_RESET); MCBSP_config(hMcbsp1, &mcbspCfg0); }

Programming the Serial Port using the DSP/BIOS GUI Few remarks: (1) Notice that values in the code generated are the same as the values inserted using the GUI interface. /* Do *not* directly modify this file. It was */ /* Config Structures */ MCBSP_Config mcbspCfg0 = { 0x00008000, /* Serial Port Control Reg. (SPCR) */ 0x000000A0, /* Receiver Control Reg. (RCR) */ 0x000000A0, /* Transmitter Control Reg. (XCR) */ 0x203F1F0F, /* Sample-Rate Generator Reg. (SRGR) */ 0x00000000, /* Multichannel Control Reg. (MCR) */ 0x00000000, /* Receiver Channel Enable(RCER) */ 0x00000000, /* Transmitter Channel Enable(XCER) */ 0x00000A00 /* Pin Control Reg. (PCR) */ };

Programming the Serial Port using the DSP/BIOS GUI Few remarks: (2) Do not forget to close the serial port after use. (3) To visualise the output of the logprintf () function make sure that the Message Log window is open (DSP/BIOS > Message Log).

Programming the Serial Port - CSL (4/4) Practical example Project name: mcbsp_staticcfg.pjt Location: \Code\Chapter 06 - McBSP\Static_CSL_Config\ Extra Topic: Digital Loopback

Chapter 6 Multi-channel Buffered Serial Port (McBSP) - End -