|
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。 部分代码如下 input mcasp_afsx,. O9 o. u. a) L* u5 A+ N
input mcasp_ahclkx,, n$ m/ O0 Z: P8 k' } p9 d$ o) l) S
input mcasp_aclkx,& w- w+ w) z( l5 a
input axr0,; E$ m/ l2 D/ ^ x9 f& t1 ~
: k2 [: h$ i$ h. g h7 moutput mcasp_afsr,6 t2 H4 Q; s1 k. t
output mcasp_ahclkr,
. x( A# g# v0 M" y8 Poutput mcasp_aclkr,& S1 t, |" S/ A8 B O! O. ~
output axr1,2 J% N& N; Q, o
assign mcasp_afsr = mcasp_afsx;
" J0 ~/ t! N& _assign mcasp_aclkr = mcasp_aclkx;
' f/ |6 L' Y9 L" i; T9 x5 vassign mcasp_ahclkr = mcasp_ahclkx;" D, ^3 j8 _- q. n3 L% s
assign axr1 = axr0;
! p$ n! a |, N. O% @; c% h$ B+ N, _5 _9 m
在OMAPL138这端,通过axr0接口发固定的数,axr1接收。 在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。 一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。 部分代码如下,关于edma3的部分未做变化。 0 M3 @: q( Q8 O8 `( a" k5 P9 U9 C7 @ G
static void McASPI2SConfigure(void)! f: x( N0 H& V/ I6 n/ ]
{
$ d: T4 ?9 R$ P6 B; ]McASPRxReset(SOC_MCASP_0_CTRL_REGS);
' M2 [+ Y _5 i4 g% h d& v. y8 xMcASPTxReset(SOC_MCASP_0_CTRL_REGS); /* Enable the FIFOs for DMA transfer */
+ U! `) f8 l( `! \0 J8 ]" NMcASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
6 ]5 _, Z8 l0 m F' EMcASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1); /* Set I2S format in the transmitter/receiver format units */" x' |' s, ^# Q% j; L6 M+ |
McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,2 K C$ o8 E& h; q
MCASP_RX_MODE_DMA);
0 t: E& Q8 a+ U+ d1 u9 p! |McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
* s D# _" i: n2 h: @MCASP_TX_MODE_DMA); /* Configure the frame sync. I2S shall work in TDM format with 2 slots */
. N) o4 x4 n0 b$ UMcASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, / q8 ~! D6 a( j S) `2 l/ [
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);" C" ]; x3 B/ T5 L4 _, D( g4 N1 N
McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD,
: |' U. `7 j' z T5 j3 JMCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE); /* configure the clock for receiver */
: }: [! ~+ q" V) l( KMcASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);$ _# [$ O O; W# \6 Z% s( T
McASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE); : E4 y" u4 s( l) K) t* H9 `3 U
McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,
0 G8 r* U! P- P0 c+ ]0 ?0x00, 0xFF); /* configure the clock for transmitter */
) f- R, H |+ x8 c" v9 uMcASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);# C$ \2 \) s' \- s E
McASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
* [0 w h% V* bMcASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,
5 ]+ C; N9 h7 s0x00, 0xFF);. S" q/ y8 Y4 ] t/ F; B
3 D( |* D1 e4 B: U6 ~ z, Y. P4 G
/* Enable synchronization of RX and TX sections */
1 {# \3 c I) _! ~# j0 @( LMcASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS); /* Enable the transmitter/receiver slots. I2S uses 2 slots */! N: c5 J9 ^) l- W& o4 \
McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
+ c+ K% U m1 v* S: H7 j+ ZMcASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); /*
2 m1 v$ H+ g$ }** Set the serializers, Currently only one serializer is set as
( o! v2 I7 t7 |- M6 q4 W+ {& S5 `5 w** transmitter and one serializer as receiver.
6 s& V) @6 a: B. g*/
/ k7 |$ v, Q: \4 ]% fMcASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);3 v/ b8 a. ]# ~5 o' v; b ?" s7 v& F
McASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX); /*7 R7 z0 m( M2 a4 u. X1 t, F0 j
** Configure the McASP pins 4 u. @6 C! R. d( q! ^3 L
** Input - Frame Sync, Clock and Serializer Rx
( Z6 }7 X7 w% y** Output - Serializer Tx is connected to the input of the codec ' C; {5 d- G! H5 N6 j
*/$ Z2 s8 X0 e( d4 O8 b) U
McASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);
- j( J8 i- Q# j! S9 v3 q; PMcASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX)); W0 e/ ^% j9 x3 v" s0 O
McASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX n9 ?% P7 S2 P% W6 m. {
| MCASP_PIN_ACLKX& F+ U; o* ?2 u
| MCASP_PIN_AHCLKX/ k& u6 g% s) o r6 D4 M( d5 _+ g
| MCASP_PIN_AXR(MCASP_XSER_RX)); /* Enable error interrupts for McASP */
1 |* e1 \" o& [' q5 ~% ]McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR 4 j- U) S. P6 Y+ V3 O- q& D: l
| MCASP_TX_CLKFAIL 0 J" Y4 G# @* I- t1 \0 ]
| MCASP_TX_SYNCERROR3 J: m$ D' A+ z5 ]; D4 o
| MCASP_TX_UNDERRUN); McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR
- |- Z- M& F0 V| MCASP_RX_CLKFAIL
t4 p: @2 [ y4 X; G| MCASP_RX_SYNCERROR
+ g, |8 }, d2 U4 U4 y% B| MCASP_RX_OVERRUN);/ d. u- J) X! O+ I8 v
} static void I2SDataTxRxActivate(void)* N7 w$ E# t( P' [' k+ k& z: K
{( q& h) o2 ^1 s6 c0 ^ H, L8 @
/* Start the clocks */
: U m& w. l9 F u& m% U/ D" SMcASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);# Q2 H$ l( [' g( N o9 Z' V, J
McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL); /* Enable EDMA for the transfer */
( Z+ q. H* Y4 w2 G! s9 n; _EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,$ ^% h* ]1 x, o4 d/ T/ E
EDMA3_TRIG_MODE_EVENT);
$ C9 H+ c' g! D; Z4 K" N2 c; HEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS,
/ n1 T/ Y: H3 g6 rEDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT); /* Activate the serializers */
! A' |# M0 R7 ^McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);6 `, s1 C' f" y1 p
McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS); /* make sure that the XDATA bit is cleared to zero */0 ?) P6 ~8 [& o" f
while(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY); /* Activate the state machines */
- J/ ^- M; s& w! B+ LMcASPRxEnable(SOC_MCASP_0_CTRL_REGS);
% B5 c y2 N6 kMcASPTxEnable(SOC_MCASP_0_CTRL_REGS);- e7 J1 b/ k$ I! d- n
}
6 u# D( l, t6 D" h: ]请问:问题出在哪了,时钟按照这样配是否有错。 另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0. + B8 [& ~9 j/ X
|