|
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。 部分代码如下 input mcasp_afsx,: {; C2 O; l( U: x0 v* q9 P! z
input mcasp_ahclkx,: S0 ?& U8 G9 j
input mcasp_aclkx,
) E, L' \! x/ @: ~: T+ d1 i7 winput axr0,
3 h1 k2 M- s* E( q% Z+ Z6 z5 I: D4 L1 t; o
output mcasp_afsr,# f( |. I, {/ ~5 E. G
output mcasp_ahclkr,
+ G0 b' r4 O8 V3 N& ] ooutput mcasp_aclkr,
% N4 p% c c x, ]( H3 \6 g$ [! Doutput axr1,
- y8 j* e; B; e0 [* _+ U; E$ O$ | assign mcasp_afsr = mcasp_afsx;& _- n( S: Q. L; W* q
assign mcasp_aclkr = mcasp_aclkx;
4 ^+ H& u7 r# L! r# Sassign mcasp_ahclkr = mcasp_ahclkx;5 ?( A; c6 g8 T) [- k7 T
assign axr1 = axr0;
# D, J0 G1 f) P- l' A9 q( H( b' W9 O9 {4 S7 z
在OMAPL138这端,通过axr0接口发固定的数,axr1接收。 在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。 一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。 部分代码如下,关于edma3的部分未做变化。
, W0 I$ H% v. S+ F' q: c8 g0 ostatic void McASPI2SConfigure(void)3 V& b; V) s0 P; e
{! w+ _/ i; K2 G
McASPRxReset(SOC_MCASP_0_CTRL_REGS); u# U) N4 ^% P$ I. W
McASPTxReset(SOC_MCASP_0_CTRL_REGS); /* Enable the FIFOs for DMA transfer */+ U5 p7 T3 D9 x4 I4 q1 ^
McASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);' |8 T7 ~0 W! Z$ t
McASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1); /* Set I2S format in the transmitter/receiver format units */# W! {: C4 q2 A) N2 M$ A, n( X
McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
+ U+ s1 s9 W7 ~4 ^" v. ^% {) |MCASP_RX_MODE_DMA);
; m8 g# T" v1 QMcASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,% R) j* M& V& k9 d1 K- {& U
MCASP_TX_MODE_DMA); /* Configure the frame sync. I2S shall work in TDM format with 2 slots */, @& ^4 J R! B: l/ v
McASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, 8 B/ S+ m0 ~! ^
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);( m/ {5 ~1 P7 b* ^& Z- _% R+ D
McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD, : s k5 q) N3 q3 |0 A" A8 [7 E
MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE); /* configure the clock for receiver */# o* `* z( E7 R) j4 M
McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);
, m, W( X- ]) PMcASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE); 6 i2 |; Q6 C4 m6 R
McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,. \2 Q4 @1 r2 K$ w
0x00, 0xFF); /* configure the clock for transmitter */4 _5 E3 J4 r( R D* w
McASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);
Q- ?' i5 H1 ~3 X$ O6 RMcASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
% t5 W+ }3 l4 @1 M- i* OMcASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,# `$ \* y; m$ u( {' V u9 Q
0x00, 0xFF);
1 E* v" l- P5 ]$ c: U9 x+ z' t
: P- C: Q& F; Y$ ^1 h/* Enable synchronization of RX and TX sections */ , l. C% T( a5 ^7 T* r8 t
McASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS); /* Enable the transmitter/receiver slots. I2S uses 2 slots */
) Z! E x' ~/ Z4 {. W( U& ^- e0 O0 ?McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
' G9 s, J6 D0 TMcASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); /*; A3 @* y; M: x& d" Y2 {7 ]2 O
** Set the serializers, Currently only one serializer is set as; C( i: M1 k! @% M6 b6 e& l
** transmitter and one serializer as receiver.6 E& Q1 Q M% y+ }
*/
7 I9 L9 M" R; t6 v7 ?McASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
- z' ]# d+ E1 p- P6 NMcASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX); /*
1 p7 }3 e+ H ^* N5 G** Configure the McASP pins
1 \2 C; s* y# a( H* n** Input - Frame Sync, Clock and Serializer Rx
( | X2 J$ {$ t" h** Output - Serializer Tx is connected to the input of the codec ) z/ c& ]2 [! P: K( O: ~
*/* x/ {. r% D* z: D2 a
McASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);
; G) V# [$ p W. W4 @McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));6 e$ Z ~! Z: K& D, }/ { b4 @
McASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX' t! u7 K7 z( H1 F
| MCASP_PIN_ACLKX
8 _9 V) S7 U. K& @| MCASP_PIN_AHCLKX
/ X4 l& d; ^5 b5 T| MCASP_PIN_AXR(MCASP_XSER_RX)); /* Enable error interrupts for McASP */
/ q& f* f3 P" C5 u2 qMcASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR * ]2 H' B% o3 w, p$ m
| MCASP_TX_CLKFAIL " y* Y/ g& h. r% p+ Y+ J6 h' P2 E
| MCASP_TX_SYNCERROR6 E3 \1 R+ d2 L# a, l5 F% Q$ A
| MCASP_TX_UNDERRUN); McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR
7 L- x0 g8 R& p4 ^: w9 g4 v7 w| MCASP_RX_CLKFAIL2 |, l, b3 z. j& a9 p/ o
| MCASP_RX_SYNCERROR 0 b' ^. u& i/ {# M7 w+ n
| MCASP_RX_OVERRUN);6 z+ g/ b0 U0 K! J4 R( i) w
} static void I2SDataTxRxActivate(void)4 A# X% T; q1 i' H
{
F* G: L h5 E7 y' m9 U3 {; ~/* Start the clocks */( c4 E- n1 ^) D* d- H
McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);
0 H: U2 t7 h. x) }8 vMcASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL); /* Enable EDMA for the transfer */
! V9 h7 `5 c: F; `- z8 q5 o Z8 xEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,
9 Z: ~" Z' Y$ i7 tEDMA3_TRIG_MODE_EVENT);
. j- L2 {3 }, f9 R/ Q! eEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, 7 Q! `$ m( \+ g/ y. ~
EDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT); /* Activate the serializers */4 u: o) O8 [2 u! R! U; E
McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);
4 J# ~& Y+ _. u) S8 iMcASPTxSerActivate(SOC_MCASP_0_CTRL_REGS); /* make sure that the XDATA bit is cleared to zero */5 C" {" r: E9 P) @7 `9 s
while(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY); /* Activate the state machines */
" n5 {7 t* D- K5 u9 `& zMcASPRxEnable(SOC_MCASP_0_CTRL_REGS);2 {- R& f ?" T
McASPTxEnable(SOC_MCASP_0_CTRL_REGS);
# J: ^) f* j7 w% s}
/ H& \' P( }! f5 x) E请问:问题出在哪了,时钟按照这样配是否有错。 另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0. 9 n4 F. G# R- e5 d& E
|