|
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。 部分代码如下 input mcasp_afsx,
3 }8 m. I' X# i- }input mcasp_ahclkx,
z! o, i3 [* X- a _input mcasp_aclkx,
; ^" q& w* d5 T; ? X; ninput axr0,8 U( D4 Q, k5 [
& q+ y8 q! `0 W c5 J) soutput mcasp_afsr,
8 v2 @' U* M0 boutput mcasp_ahclkr,
/ V8 \ m2 E9 y: g# R4 O, k) }output mcasp_aclkr,
7 j N1 G* r) uoutput axr1,/ _. M! g3 k; {
assign mcasp_afsr = mcasp_afsx;: ]+ l$ v* f* ^3 H
assign mcasp_aclkr = mcasp_aclkx;
* i/ e' V+ E2 Massign mcasp_ahclkr = mcasp_ahclkx;
* B1 y" Z' p3 R: \assign axr1 = axr0; ! M& a$ M+ Y& b6 m! N/ Z- Z! Q
2 s! E" |# Q, j) t# G
在OMAPL138这端,通过axr0接口发固定的数,axr1接收。 在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。 一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。 部分代码如下,关于edma3的部分未做变化。 6 b6 Q4 g" T F
static void McASPI2SConfigure(void)& k5 `' C% d$ h! e7 \
{
; N5 F1 k q/ @McASPRxReset(SOC_MCASP_0_CTRL_REGS);
# R* f8 B' p* N6 X e7 ^; y! TMcASPTxReset(SOC_MCASP_0_CTRL_REGS); /* Enable the FIFOs for DMA transfer */
9 G5 w/ q" E a1 A0 W, cMcASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
& c8 J8 x5 u' PMcASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1); /* Set I2S format in the transmitter/receiver format units */" ^1 l6 C2 P8 k1 b& j
McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
8 O8 g; d' B' \; h- WMCASP_RX_MODE_DMA); R9 J6 q) G9 [" X( u
McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
0 N8 R( ~% p; ~2 r O) I4 T/ _8 |; rMCASP_TX_MODE_DMA); /* Configure the frame sync. I2S shall work in TDM format with 2 slots */5 m0 C G# b# {
McASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, 4 q' J, K! E0 x1 g
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);2 x8 T& e ]7 {' a
McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD,
) R( {2 H! i+ ~( f: x% {MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE); /* configure the clock for receiver */
8 }" K& b; j- D( l" D( D' OMcASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);
) @+ E- F; q9 @( vMcASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE); 8 y/ U6 I5 S+ ?, S' G/ ]
McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,. o3 f V* L, D7 A$ h1 N# J) C
0x00, 0xFF); /* configure the clock for transmitter */
: O# J7 u& I, YMcASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);# k+ i5 w D. {3 R& G3 c; t
McASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
, | u9 i, s. x& @9 c2 @4 P. XMcASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,
& Z6 [' [, I- O0x00, 0xFF);& G) b c$ K" f* s3 [5 x& P
2 ]8 U- W, [* Z7 ^" v2 a* f/* Enable synchronization of RX and TX sections */ . R& J( r! x0 V3 z6 z- s. o
McASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS); /* Enable the transmitter/receiver slots. I2S uses 2 slots */8 T+ X# M1 b+ j$ O% n# e, ^& g
McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);. i0 Z5 {8 c: ~; J3 ~/ ]8 M) P9 F
McASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); /*+ d( A: B9 _ N9 f, k
** Set the serializers, Currently only one serializer is set as
3 h8 ?& J# a4 f) ~ K1 v** transmitter and one serializer as receiver.3 `9 T3 o8 ?$ ?$ {* Q
*/
* ^2 O7 s! O' N% |" }/ o: ?0 B# vMcASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);% m: w& ^) K3 F4 \% z. e
McASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX); /*7 T% a8 t' b7 [+ Q
** Configure the McASP pins ) H J0 p3 R& X
** Input - Frame Sync, Clock and Serializer Rx
% n7 I8 Q% f7 }. D** Output - Serializer Tx is connected to the input of the codec 6 c- _- _0 x0 a3 G& A; |, ]
*/
( i" Z2 w) R) w4 W0 x) L3 k: NMcASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);* e0 z6 L3 @' _* H2 i4 A/ ]
McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));
9 }* A2 b Q9 w; ]6 B: w4 l$ q1 \McASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX2 s5 C" {% ]3 }' A
| MCASP_PIN_ACLKX
0 g! ?, ~1 w5 S) ^| MCASP_PIN_AHCLKX' m3 m! B. w0 y' R7 @! r
| MCASP_PIN_AXR(MCASP_XSER_RX)); /* Enable error interrupts for McASP */' v/ I9 f; ?2 |; z
McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR
! \+ p8 h/ s. a6 s* a| MCASP_TX_CLKFAIL 6 h* ~. ^8 F) t- |& i
| MCASP_TX_SYNCERROR: u* |& E4 q6 E7 S- w' l: |+ A
| MCASP_TX_UNDERRUN); McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR
n2 L- C( h# B) ?! _| MCASP_RX_CLKFAIL; Y* {1 o2 {6 C* G$ h$ A
| MCASP_RX_SYNCERROR
9 T D% p, p3 g* D V| MCASP_RX_OVERRUN);4 B/ W* }( p8 \* H3 N% E
} static void I2SDataTxRxActivate(void)( n" W$ D" L9 k. e% b: a
{
0 b, B7 ^4 G7 l; N. |' ?/* Start the clocks */
8 ^& v! @& d6 u; M; j GMcASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);: `- _3 I6 Z! r
McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL); /* Enable EDMA for the transfer */+ f' S* w$ v% F
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,; w- v# O3 T2 j1 R) _# {" ^# ^
EDMA3_TRIG_MODE_EVENT);
: E9 K( a8 t" R! j: R+ t/ dEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS,
! A% W% M/ \. [1 a bEDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT); /* Activate the serializers */7 S0 U- Z* g" Y2 K3 |
McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);* s/ e# Z) Y, p. H9 s$ A
McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS); /* make sure that the XDATA bit is cleared to zero */3 q; ^3 J/ k$ H$ ~* S! h
while(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY); /* Activate the state machines */; T2 l$ a1 e: w* y, H$ l! |: O
McASPRxEnable(SOC_MCASP_0_CTRL_REGS);, s+ P/ S( y- e4 O" t4 G
McASPTxEnable(SOC_MCASP_0_CTRL_REGS); p& D/ Y2 y8 T; p/ ^8 a
} ! T" D5 g3 i; L" q: K1 [
请问:问题出在哪了,时钟按照这样配是否有错。 另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0. & Q, i e, K4 V" U$ m! j2 _
|