|
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。 部分代码如下 input mcasp_afsx,- b2 [0 N, g7 G8 B
input mcasp_ahclkx,
. U. l4 V( O1 x4 W; D( Dinput mcasp_aclkx,
u6 ]2 q3 d5 Q6 R& j% `input axr0,% J- B* j ~( a; h
# o9 Q! {+ s! ?2 h* Noutput mcasp_afsr,
& I7 M4 s* |+ F D& ~output mcasp_ahclkr,
' [( w! _3 h Ioutput mcasp_aclkr,
7 B! V) Y3 |$ U) y# H( M) r4 ^# ooutput axr1,
5 |+ C7 j. V8 v9 r' C7 u' c assign mcasp_afsr = mcasp_afsx;" Q" _, k8 g1 |0 o( ~
assign mcasp_aclkr = mcasp_aclkx;
8 }! R$ O8 k) h0 G7 kassign mcasp_ahclkr = mcasp_ahclkx;
5 P5 ?$ n( ?, x( [, Rassign axr1 = axr0; 3 r6 d' W( p7 o: m
* o6 v6 y. d' Z! j4 f; s/ V- k! s
在OMAPL138这端,通过axr0接口发固定的数,axr1接收。 在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。 一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。 部分代码如下,关于edma3的部分未做变化。
0 O7 w3 D6 s; {, d) G1 estatic void McASPI2SConfigure(void). ?8 x; S: m6 y" _7 C4 H
{- Q/ M" F) Q, o# M2 G. g2 p* B
McASPRxReset(SOC_MCASP_0_CTRL_REGS);9 X' P: X" f# T! h( F2 {
McASPTxReset(SOC_MCASP_0_CTRL_REGS); /* Enable the FIFOs for DMA transfer */ Z9 U5 c7 ~) h W
McASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);; o- C/ T3 @( T- j# {+ B
McASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1); /* Set I2S format in the transmitter/receiver format units */: y4 U( a# b- m
McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
* M7 ?2 E4 R, r1 t8 v2 A- yMCASP_RX_MODE_DMA);5 a' U+ C6 T; E3 @; B. ~* ]
McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,7 h0 x8 r8 x, V( L
MCASP_TX_MODE_DMA); /* Configure the frame sync. I2S shall work in TDM format with 2 slots */
5 w7 q; H: f6 t7 f1 ZMcASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD,
$ t( @7 u$ E4 s( UMCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);- U4 ?) M$ R- s& B% K4 `, c- |& s
McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD,
7 i+ M; v; c# s" RMCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE); /* configure the clock for receiver */
$ o6 U% z, a; Z" I7 v' V8 ]McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);6 H& A7 L5 K- n" J: ^% U
McASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE); 4 ]' U0 v1 c' f+ _# N% L' W
McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,' u8 t9 k" Y6 W. v3 V! X
0x00, 0xFF); /* configure the clock for transmitter */
- ^8 z* z* [+ ^8 F1 v1 gMcASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);) |( d3 a5 w+ g! j
McASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE); F3 l7 c, H3 t- D5 x f! Q
McASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,' N# c- s1 O5 J3 c
0x00, 0xFF);* c9 q1 `6 H3 c
7 X6 _! P d9 u! q# j* I
/* Enable synchronization of RX and TX sections */ 8 x) |* A3 G0 X. x+ a1 L; L
McASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS); /* Enable the transmitter/receiver slots. I2S uses 2 slots */
* O. x2 m$ i0 |: ?/ _/ S* LMcASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);. W9 K0 m5 ]: D6 w' a( E/ \
McASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); /*- {9 s. Z. w+ _# z5 p
** Set the serializers, Currently only one serializer is set as* o. _. _/ U: a) S' @
** transmitter and one serializer as receiver.* l0 d4 k W- M: B. w* J+ q. M4 q" }: O
*/
6 B v* ^# L( A" X# x4 W1 xMcASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
0 D) E# o* @" O0 g: JMcASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX); /*
9 R3 |; r6 g$ p, o3 j** Configure the McASP pins
/ i1 s- p, ^' t u8 n' W- s7 u+ l1 }# Q** Input - Frame Sync, Clock and Serializer Rx
9 ^; c8 J) [- z0 A- \& l/ S** Output - Serializer Tx is connected to the input of the codec , Z% ~( L& V, S' O8 E. g
*/8 P3 c; M' j- s8 Y8 d3 _5 N8 ^
McASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);
* v/ ^( {! j) k' _1 _McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX)); p( \/ |8 f3 S: u; v
McASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX
9 u% d5 x) l" ~$ }7 m: c- Y S1 a| MCASP_PIN_ACLKX4 R4 J/ }; \# ^ L9 i: I# g
| MCASP_PIN_AHCLKX7 P) q6 s7 a, O0 z: W
| MCASP_PIN_AXR(MCASP_XSER_RX)); /* Enable error interrupts for McASP */
- i% W# X& Q, J, J, N3 Q% n wMcASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR
7 i2 A0 G: ^, t' ^$ s2 ]' d" M| MCASP_TX_CLKFAIL
$ g- Z, d, n8 p& [8 g" W| MCASP_TX_SYNCERROR2 J8 u8 z3 B- s+ V6 F
| MCASP_TX_UNDERRUN); McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR / |% u4 ?! W# k1 B9 |5 P9 R
| MCASP_RX_CLKFAIL- B. C3 D" G' Q) ^7 {
| MCASP_RX_SYNCERROR
; X+ V7 B! W$ K- x8 Z- R| MCASP_RX_OVERRUN);) `- Y; A$ o5 M, r+ e
} static void I2SDataTxRxActivate(void)
- \ |- }4 @, k4 v. V{
+ J8 L( C/ i2 h/* Start the clocks */& ~* d2 P _3 ]7 i, a% u: c9 C7 g2 E" E
McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);; w1 R! H7 k/ E8 C; r8 n( w
McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL); /* Enable EDMA for the transfer */
y: T0 O* @) _7 L: V4 aEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,
/ @% N+ q) i5 SEDMA3_TRIG_MODE_EVENT);1 ~. {/ } s; d
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS,
4 N+ Q- _( R L) MEDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT); /* Activate the serializers */
* t( n$ c- P/ C3 f' nMcASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);
8 v/ @) v8 U8 iMcASPTxSerActivate(SOC_MCASP_0_CTRL_REGS); /* make sure that the XDATA bit is cleared to zero */
. i' i t: }6 V8 R1 D! s# Owhile(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY); /* Activate the state machines */, ~1 m- j& A3 b) b9 q
McASPRxEnable(SOC_MCASP_0_CTRL_REGS);+ Z: b# d, d8 j, H
McASPTxEnable(SOC_MCASP_0_CTRL_REGS);$ [$ ^8 |/ c0 [9 _( Q# _- ], _' A( ^
}
9 |3 f+ O$ x3 ~& k' {. T! }8 p请问:问题出在哪了,时钟按照这样配是否有错。 另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0. ; y, P" s0 Z3 Y" R
|