嵌入式开发者社区

标题: MCASP自环配置。 [打印本页]

作者: wapdasta    时间: 2018-11-7 13:28
标题: MCASP自环配置。
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。
部分代码如下
input mcasp_afsx,' c- B+ f5 W3 A6 v- n  ~" }
input mcasp_ahclkx,
8 n4 H# q" `$ t! c+ }input mcasp_aclkx,
4 e  E  t! K# S( Uinput axr0,& e0 b$ q6 p& R" q: f4 ?, W
- y: q$ m* y! D
output mcasp_afsr,! ?3 h4 D  D- c9 U, b3 h
output mcasp_ahclkr,: m4 Q# v$ w$ z9 x8 j
output mcasp_aclkr,. K6 C% V! A5 p4 l  e7 i
output axr1,
( Y) J1 ^% N+ g; N  C
assign mcasp_afsr = mcasp_afsx;
2 c9 m  E, o( Z/ B; K) u. ?; Iassign mcasp_aclkr = mcasp_aclkx;
' Q7 G4 E# ~2 Eassign mcasp_ahclkr = mcasp_ahclkx;
0 D3 l2 g9 k0 v/ S/ a9 ?) b0 L0 Q0 ?) H) Bassign axr1 = axr0;

& t" k, S3 R4 w! k# Z2 d; H: @( o* {( Y7 ~, q+ y
在OMAPL138这端,通过axr0接口发固定的数,axr1接收。
在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。
一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。
部分代码如下,关于edma3的部分未做变化。

  |2 t$ P0 R4 e
static void McASPI2SConfigure(void)  U8 o, J. Q  G6 E0 c# Z
{
' u% J1 n; w: [+ O& l2 c+ o: R  dMcASPRxReset(SOC_MCASP_0_CTRL_REGS);
  d9 a) t+ o6 w8 p' o" i5 _. YMcASPTxReset(SOC_MCASP_0_CTRL_REGS);
/* Enable the FIFOs for DMA transfer */
' I' b2 U9 w, h( v0 tMcASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
. V3 Q! X$ T# j% V' kMcASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
/* Set I2S format in the transmitter/receiver format units */
; \8 u% C$ ]  q8 N+ ~3 UMcASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,- y( C! B( x/ q: y
MCASP_RX_MODE_DMA);
( s- b  P0 B0 @. L; {' ~0 {McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
+ O3 \  X( v; K% M- B( D" P) O% sMCASP_TX_MODE_DMA);
/* Configure the frame sync. I2S shall work in TDM format with 2 slots *// J8 t( T+ K" o
McASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, ' Y3 e# {( {) @  d6 i4 I
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);6 N/ b! s. R5 T) A9 ^9 R7 T
McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD, 8 z& Y7 |6 o  q: @; A& [; b
MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE);
/* configure the clock for receiver */
2 y- Y9 P  I7 z* H) Z. t7 w) q4 aMcASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);
2 `# S, F8 A% l0 y  t+ V5 p/ @McASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE);
0 y. a3 B2 S; w7 \McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,
0 q6 G( P$ L! a, r0x00, 0xFF);
/* configure the clock for transmitter */
1 o) D/ i. u: u' R5 _0 hMcASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);
) u2 ~% ]6 w0 fMcASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
7 M% ^  w1 w6 Q9 b6 _McASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,
% B  i3 D7 o. c" [7 g9 g0x00, 0xFF);
7 C; W6 ^$ C- T8 H8 M9 D, i/ F9 T9 D/ R0 t
/* Enable synchronization of RX and TX sections */ 8 [/ ~9 f% C, {) o9 g$ i: F
McASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS);
/* Enable the transmitter/receiver slots. I2S uses 2 slots */
& W5 ]/ p* M6 h: @; {7 U, HMcASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
( c! @) c' s' M) p9 k' H  P. u2 cMcASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
/*
$ j  q1 w4 t0 h- |; a6 ~6 L** Set the serializers, Currently only one serializer is set as1 ]- ^* y% {5 A9 _" s1 }: e2 O
** transmitter and one serializer as receiver.6 T, d! U% ~: q! ?( _/ ~
*/0 S, b5 ~2 Z( ]/ Q4 [3 }" X
McASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
7 \; Z( M, w2 s3 n- {, B8 nMcASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX);
/*
- Z& L  O! j0 b+ H) i) O** Configure the McASP pins
2 o5 M0 T6 Y) n7 {" o( b+ ]- {% N** Input - Frame Sync, Clock and Serializer Rx5 \/ x; G  i& y; _# ^6 [0 P
** Output - Serializer Tx is connected to the input of the codec ) ^! L9 x- e4 X
*/3 P* P) _, L6 b5 F. Q
McASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);: k4 k8 p( Z% P9 Q; o2 S
McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));
( S- X+ t/ t# @' yMcASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX
9 ?9 R1 \5 Z, K6 a| MCASP_PIN_ACLKX
# y; Z- k8 {( E3 Y% Z| MCASP_PIN_AHCLKX6 W+ p5 ~9 b  H+ y
| MCASP_PIN_AXR(MCASP_XSER_RX));
/* Enable error interrupts for McASP */" o; c! g4 @$ C& y/ j( L2 g
McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR
' L/ x6 a8 e3 H. i/ t( O8 B: c| MCASP_TX_CLKFAIL
5 b9 {4 X" ~& t* L| MCASP_TX_SYNCERROR
9 t" q. s- U+ F| MCASP_TX_UNDERRUN);
McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR
0 O2 s- K! J4 g! t; k| MCASP_RX_CLKFAIL
5 Z4 E3 O2 m7 T* P| MCASP_RX_SYNCERROR 7 J) ]( N5 p- b' |
| MCASP_RX_OVERRUN);( b( ^% n( K/ y6 l* k" T( C' P
}
static void I2SDataTxRxActivate(void)5 B# H, ~+ P+ e; ]) w+ N
{
, z! K- F6 _# B2 z! q/* Start the clocks */- b8 ~; |7 x0 k, q+ {* J0 n
McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);; b. I' a% N5 U
McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL);
/* Enable EDMA for the transfer */7 ~2 I' e8 S0 _" C
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,
  B5 Y# i' Q2 @( gEDMA3_TRIG_MODE_EVENT);
% \7 c/ P0 _- l5 P5 y4 K. dEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS,
1 _% O' F6 s* M3 OEDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT);
/* Activate the serializers */
  n- I+ K. y2 CMcASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);
& f* u" }' r' z8 n: dMcASPTxSerActivate(SOC_MCASP_0_CTRL_REGS);
/* make sure that the XDATA bit is cleared to zero */3 [+ v" w. k7 D* e
while(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY);
/* Activate the state machines */* I1 v/ _9 y& @0 g
McASPRxEnable(SOC_MCASP_0_CTRL_REGS);
7 q1 r, a2 H. K+ X8 |McASPTxEnable(SOC_MCASP_0_CTRL_REGS);
7 G, W5 o( I- n9 U1 w}

* N* d; Q( @) n3 `* X
请问:问题出在哪了,时钟按照这样配是否有错。
另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0.
8 Y6 G- ~+ q9 y1 \$ a





欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) Powered by Discuz! X3.4