multichannel buffered serial port - people@rset

68
Multichannel Buffered Serial Port McBSP

Upload: others

Post on 13-Feb-2022

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Multichannel Buffered Serial Port - People@RSET

Multichannel Buffered Serial Port

McBSP

Page 2: Multichannel Buffered Serial Port - People@RSET

Features

The McBSP provides these functions:

Full-duplex communication.

Double-buffered data registers, which allow a continuousdata stream.

Independent framing and clocking for receive andtransmit.

Direct interface to industry-standard codecs, analoginterface chips (AICs), and other serially connectedanalog-to-digital (A/D) and digital-to-analog (D/A)devices.

External shift clock or an internal, programmablefrequency shift clock for data transfer.

Page 3: Multichannel Buffered Serial Port - People@RSET

Features

Multichannel transmit and receive of up to 128 channels

A wide selection of data sizes, including 8, 12, 16, 20, 24,

and 32 bits

µ-Law and A-Law companding

8-bit data transfers with the option of LSB or MSB first

Programmable polarity for both frame synchronization

and data clocks

Highly programmable internal clock and frame

generation.

Page 4: Multichannel Buffered Serial Port - People@RSET

McBSP Interface Signals and

Registers

The multichannel buffered serial port (McBSP) consists ofa data path and a control path, which connect to externaldevices.

Data is communicated to these external devices viaseparate pins for transmission and reception.

Control information (clocking and frame synchronization)is communicated via four other pins.

The device communicates to the McBSP via 32-bit-widecontrol registers accessible via the internal peripheral bus.

Page 5: Multichannel Buffered Serial Port - People@RSET

TMS320C671x Peripherals

Page 6: Multichannel Buffered Serial Port - People@RSET

McBSP Block Diagram

Page 7: Multichannel Buffered Serial Port - People@RSET

McBSP Interface Signals

Data is communicated via the data transmit (DX) pin for

transmission and the data receive (DR) pin for reception.

Control information (clocking and frame synchronization) is

communicated via CLKX, CLKR, FSX, and FSR.

The C6000 communicates to the McBSP via 32-bit-wide

control registers accessible via the internal peripheral bus.

Page 8: Multichannel Buffered Serial Port - People@RSET

McBSP Interface Signals

Either the CPU or the EDMA controller reads the receiveddata from the data receive register (DRR) and writes the datato be transmitted to the data transmit register (DXR).

Data written to the DXR is shifted out to DX via the transmitshift register (XSR).

Similarly, receive data on the DR pin is shifted into thereceive shift register (RSR) and copied into the receivebuffer register (RBR). RBR is then copied to DRR, whichcan be read by the CPU or the EDMA controller. This allowssimultaneous internal data movement and external datacommunications.

Page 9: Multichannel Buffered Serial Port - People@RSET

McBSP Registers

Page 10: Multichannel Buffered Serial Port - People@RSET

TMS320C671x Data Receive and Transmit

Registers (DRR/DXR) Mapping:

For devices with the EDMA peripheral, the data receive andtransmit registers (DRR and DXR) are also mapped tomemory locations 3xxxxxxxh. The DRR and DXR locations018Cxxxxh/0190xxxxh are accessible via the peripheral bus,while the 3xxxxxxxh locations are accessible via the EDMAbus.

Both the CPU and the EDMA in these devices can access theDRR and DXR in all the memory-mapped locations shown inTable. An access to any EDMA bus location is equivalent toan access to the DRR/DXR of the corresponding McBSP.

Page 11: Multichannel Buffered Serial Port - People@RSET

TMS320C671x Data Receive and Transmit

Registers (DRR/DXR) Mapping:

For example, a read from any location in 30000000h–

33FFFFFFh is equivalent to a read from the DRR of

McBSP0 at 018C0000h. A write to any location in

30000000h–33FFFFFFh is equivalent to a write to the

DXR of McBSP0 at 018C0004h.

The user has a choice of reading from/writing to the DRR

and DXR in either the 3xxxxxxxh or the

018Cxxxxh/0190xxxxh location.

Page 12: Multichannel Buffered Serial Port - People@RSET

TMS320C671x Data Receive and Transmit

Registers (DRR/DXR) Mapping:

Page 13: Multichannel Buffered Serial Port - People@RSET

McBSP CPU Interrupts and DMA

Synchronization Events

The control block consists of internal clock generation,

frame-synchronization signal generation and control of these

signals, and multichannel selection.

This control block sends notification of important interrupts

to the CPU and events to the EDMA controller via the four

signals shown in Table.

Page 14: Multichannel Buffered Serial Port - People@RSET

Serial Port Configuration

The serial port is configured via the serial portcontrol register (SPCR) and the pin controlregister (PCR).

The SPCR and PCR contain McBSP status controlbits.

The PCR is also used to configure the serial portpins as general purpose inputs or outputs duringreceiver and/or transmitter reset.

Page 15: Multichannel Buffered Serial Port - People@RSET

Serial Port Control Register

Details

Serial Port Control Register (SPCR):

Page 16: Multichannel Buffered Serial Port - People@RSET

SPCR Field Descriptions:

Page 17: Multichannel Buffered Serial Port - People@RSET

SPCR Field Descriptions:

Page 18: Multichannel Buffered Serial Port - People@RSET

SPCR Field Descriptions:

Page 19: Multichannel Buffered Serial Port - People@RSET

SPCR Field Descriptions:

Page 20: Multichannel Buffered Serial Port - People@RSET

SPCR Field Descriptions:

Page 21: Multichannel Buffered Serial Port - People@RSET

SPCR Field Descriptions:

Page 22: Multichannel Buffered Serial Port - People@RSET

Serial Port Control Register

Details Cont..

Pin Control Register (PCR):

Page 23: Multichannel Buffered Serial Port - People@RSET

PCR Field Descriptions Cont..

Page 24: Multichannel Buffered Serial Port - People@RSET

PCR Field Descriptions Cont..

Page 25: Multichannel Buffered Serial Port - People@RSET

PCR Field Descriptions Cont..

Page 26: Multichannel Buffered Serial Port - People@RSET

PCR Field Descriptions Cont..

Page 27: Multichannel Buffered Serial Port - People@RSET

Serial Port Control Registers

Receive Control Register (RCR):

Page 28: Multichannel Buffered Serial Port - People@RSET

RCR Field Descriptions

Page 29: Multichannel Buffered Serial Port - People@RSET

RCR Field Descriptions

Page 30: Multichannel Buffered Serial Port - People@RSET

RCR Field Descriptions

Page 31: Multichannel Buffered Serial Port - People@RSET

Serial Port Control Registers

Transmit Control Register (XCR):

Page 32: Multichannel Buffered Serial Port - People@RSET

XCR Field Descriptions

Page 33: Multichannel Buffered Serial Port - People@RSET

XCR Field Descriptions

Page 34: Multichannel Buffered Serial Port - People@RSET

XCR Field Descriptions

Page 35: Multichannel Buffered Serial Port - People@RSET

McBSP Standard Operation

Operation:

The receive operation is triple-buffered and the

transmit operation is double-buffered.

Transmitting Data:

DXR XSR DX

Receiving Data:

DR RSR RBR DRR

Page 36: Multichannel Buffered Serial Port - People@RSET

McBSP Standard Operation

Determining Ready Status:

RRDY and XRDY indicate the ready state of the McBSP

receiver and transmitter, respectively.

Writes and reads from the serial port can be synchronized

by any of the following methods:

Polling RRDY and XRDY

Using the events sent to the DMA or EDMA controller (REVT

and XEVT)

Using the interrupts to the CPU (RINT and XINT) that the events

generate.

Page 37: Multichannel Buffered Serial Port - People@RSET

McBSP Standard Operation

Receive Operation:

Once the receive frame synchronization signal (FSR) transitions toits active state, it is detected on the first falling edge of the receiver’sCLKR.

The data on the DR pin is then shifted into the receive shift register(RSR) after the appropriate data delay as set by RDATDLY.

The contents of RSR is copied to RBR at the end of every elementon the rising edge of the clock, provided RBR is not full with theprevious data.

Then, an RBR-to-DRR copy activates the RRDY status bit to 1 onthe following falling edge of CLKR. This indicates that the receivedata register (DRR) is ready with the data to be read by the CPU orthe DMA controller.

RRDY is deactivated when the DRR is read by the CPU or theDMA controller.

Page 38: Multichannel Buffered Serial Port - People@RSET

Receive Operation Cont..

Receive Timing Diagram:

Page 39: Multichannel Buffered Serial Port - People@RSET

McBSP Standard Operation

Transmit Operation:

Once transmit frame synchronization occurs, the valuein the transmit shift register, XSR, is shifted out anddriven on the DX pin after the appropriate data delay asset by XDATDLY.

XRDY is activated after every DXR-to-XSR copy onthe following falling edge of CLKX, indicating that thedata transmit register (DXR) can be written with thenext data to be transmitted.

XRDY is deactivated when the DXR is written by theCPU or the DMA controller.

Page 40: Multichannel Buffered Serial Port - People@RSET

Transmit Operation Cont..

Transmitter Timing Diagram:

Page 41: Multichannel Buffered Serial Port - People@RSET

Multiphase Frame Example: AC97

The Audio Codec ’97 (AC97) standard, which uses the dual-

phase frame feature. The first phase consists of a single 16-bit

element. The second phase consists of 12 20-bit elements. The

phases are configured as follows:

Page 42: Multichannel Buffered Serial Port - People@RSET

Multiphase Frame Example: AC97

Page 43: Multichannel Buffered Serial Port - People@RSET

DSP LAB - McBSP Interfacing

Page 44: Multichannel Buffered Serial Port - People@RSET

6713 DSK

Page 45: Multichannel Buffered Serial Port - People@RSET

AIC23 CODEC INTERFACING

The DSP interfaces to analog audio signals throughan on-board AIC23 codec.

The codec samples analog signals on themicrophone or line inputs and converts them intodigital data so it can be processed by the DSP.When the DSP is finished with the data it uses thecodec to convert the samples back into analogsignals on the line and headphone outputs so theuser can hear the output.

Page 46: Multichannel Buffered Serial Port - People@RSET

AIC23CODEC INTERFACING Cont..

The codec communicates using two serial channels, one tocontrol the codec’s internal configuration registers and oneto send and receive digital audio samples. McBSP0 is usedas the unidirectional control channel.

It should be programmed to send a 16-bit control word tothe AIC23 in SPI format.

McBSP1 is used as the bi-directional data channel.

The DSK generally use a 16-bit sample width with thecodec in master mode.

The preferred serial format is DSP mode which is designedspecifically to operate with the McBSP ports on TI DSPs.

Page 47: Multichannel Buffered Serial Port - People@RSET

TMS320C6713 DSK CODEC INTERFACE

Page 48: Multichannel Buffered Serial Port - People@RSET

AIC23 Codec

The TLV320AIC23 is a high-performance stereo

audio codec.

Data-transfer word lengths of 16, 20, 24, and 32

bits, with sample rates from 8 kHz to 96 kHz, are

supported.

The codec has a 12MHz system clock.

The internal sample rate generate subdivides the

12MHz clock to generate common frequencies such

as 48KHz, 44.1KHz and 8KHz.

Page 49: Multichannel Buffered Serial Port - People@RSET

Interfacing Signals

Page 50: Multichannel Buffered Serial Port - People@RSET

Modes of Communication

SPI Mode : The control interface. In SPI mode, SDIN carries the serial data, SCLK is the

serial clock and CS latches the data word into theTLV320AIC23.

A control word consists of 16 bits, starting with theMSB. The data bits are latched on the rising edge ofSCLK. A rising edge on CS after the 16th rising clockedge latches the data word into the AIC .

The control word is divided into two parts. The firstpart is the address block, the second part is the datablock: B[15:9] Control Address Bits

B[8:0] Control Data Bits

Page 51: Multichannel Buffered Serial Port - People@RSET

SPI Protocol: CLKSTP

SPIE protocol is a 4-wire interface composed of serial data in (master in slave out orMISO),

serial data out (master out slave in or MOSI),

shift clock (SCK),

active (low) slave enable (SS) signal.

Communication between the master and the slave isdetermined by the presence or absence of the master clock.Data transfer is initiated by the detection of the masterclock and is terminated on absence of the master clock.The slave has to be enabled during this period of transfer.

When the McBSP is the master, the slave enable is derivedfrom the master transmit frame sync pulse, FSX.

Page 52: Multichannel Buffered Serial Port - People@RSET

SPI Protocol: CLKSTP

SPI Configuration: McBSP as the Master

SPI Configuration: McBSP as the Slave

Page 53: Multichannel Buffered Serial Port - People@RSET

Modes of Communication Cont..

DSP mode: Digital Audio-Interface Mode

The DSP mode is compatible with the McBSP ports of

TI DSPs.

LRCIN and LRCOUT must be connected to the Frame

Sync signal of the McBSP. A falling edge on LRCIN or

LRCOUT starts the data transfer.

The left-channel data consists of the first data word,

which is immediately followed by the right channel

data word.

Input word length is defined by the IWL register.

Page 54: Multichannel Buffered Serial Port - People@RSET

AIC23 Register Map

Page 55: Multichannel Buffered Serial Port - People@RSET

Codec Control Registers

Page 56: Multichannel Buffered Serial Port - People@RSET

Codec Control Registers

Page 57: Multichannel Buffered Serial Port - People@RSET

Codec Control Registers

Page 58: Multichannel Buffered Serial Port - People@RSET

Codec Control Registers

Page 59: Multichannel Buffered Serial Port - People@RSET

Codec Control Registers

Page 60: Multichannel Buffered Serial Port - People@RSET

Codec Control Registers

Page 61: Multichannel Buffered Serial Port - People@RSET

Codec Control Registers Cont..

Page 62: Multichannel Buffered Serial Port - People@RSET

Sample Rate Control

Page 63: Multichannel Buffered Serial Port - People@RSET

Codec Connection Diagram

Page 64: Multichannel Buffered Serial Port - People@RSET

McBSP Control Register Values

void mcbsp0_init()

{

*(unsigned volatile int*)MCBSP0_SPCR = 0;

*(unsigned volatile int*)MCBSP0_PCR=0x00000A0A;

*(unsigned volatile int*)MCBSP0_RCR=0;

*(unsigned volatile int*)MCBSP0_XCR=0x00010040;

*(unsigned volatile int*)MCBSP0_SPCR=0x00C11001;

*(unsigned volatile int*)MCBSP0_SRGR=0x10001999;

}

void mcbsp1_init()

{

*(unsigned volatile int*)MCBSP1_SPCR = 0;

*(unsigned volatile int*)MCBSP1_PCR=0x00000003;

*(unsigned volatile int*)MCBSP1_RCR=0x00000140;

*(unsigned volatile int*)MCBSP1_XCR=0x00000140;

*(unsigned volatile int*)MCBSP1_SPCR=0x00C10001;

}

Page 65: Multichannel Buffered Serial Port - People@RSET

DSK6713_AIC23_Config config = {\ 0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Leftline input channel

volume */\ 0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel

volume*/\ 0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel

headphone volume */\ 0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel

headphone volume */\ 0x0011, /* 4 DSK6713_AIC23_ANAPATH Analog audio path

control */\ 0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control

*/\ 0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control

*/\ 0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format

*/\ 0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */\ 0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */

\ };

Page 66: Multichannel Buffered Serial Port - People@RSET

Serial Port Control Register..

Sample Rate Generator Register (SRGR):

Page 67: Multichannel Buffered Serial Port - People@RSET

SRGR Field Descriptions Cont..

Page 68: Multichannel Buffered Serial Port - People@RSET

SRGR Field Descriptions Cont..