|
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。 部分代码如下 input mcasp_afsx,4 ^; a- w# q5 v! d1 l6 f
input mcasp_ahclkx,) b5 }' l! [5 b! C# U D9 U" Z
input mcasp_aclkx, [( g& H7 S w9 @7 h+ M
input axr0, u, M. n T! \5 f2 ^. f
" J( Q+ | [9 H$ O' y5 f" ~4 l2 @
output mcasp_afsr,
1 v8 Q6 B" q/ w. v8 youtput mcasp_ahclkr,, @9 D5 e' S2 \' y/ T: E+ Y# {. Y
output mcasp_aclkr,
: m: a. j5 S u Moutput axr1,
5 H3 K. d5 ]2 x' P; I assign mcasp_afsr = mcasp_afsx;7 x& T+ A( \- h9 _1 l. q
assign mcasp_aclkr = mcasp_aclkx;* q! ^% j$ P: Q K
assign mcasp_ahclkr = mcasp_ahclkx;
6 c8 I1 K+ z [" B$ t5 p$ J5 Iassign axr1 = axr0;
* \+ B0 F6 J" H7 T# M/ U- @. F+ Q6 P3 D- `
在OMAPL138这端,通过axr0接口发固定的数,axr1接收。 在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。 一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。 部分代码如下,关于edma3的部分未做变化。
) p" q/ F: C0 g: x8 _, d- ~static void McASPI2SConfigure(void)
. y. Z+ `7 ?/ p' \{
6 Q6 I, A' y8 b e/ fMcASPRxReset(SOC_MCASP_0_CTRL_REGS);
- ]$ E" i8 q4 UMcASPTxReset(SOC_MCASP_0_CTRL_REGS); /* Enable the FIFOs for DMA transfer */1 U9 b" F2 m! i
McASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);, B) B0 }* `* h6 M/ z! n+ ?9 H2 x
McASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1); /* Set I2S format in the transmitter/receiver format units */
8 z# ~' H8 `& J- S3 iMcASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
% Q- g9 i2 |- Y& ^MCASP_RX_MODE_DMA);
$ c7 a; X5 _; A: JMcASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,! }6 v" y& f; }/ ?6 t7 Z- w0 ]
MCASP_TX_MODE_DMA); /* Configure the frame sync. I2S shall work in TDM format with 2 slots */
: y& i# a* |% s% pMcASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD,
, e9 K/ j5 _/ ?9 r5 O) ?, @6 gMCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);. m& z- d3 {; r" g% c3 Y( d% c
McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD,
5 e% {* u6 H3 {9 f/ J' ^2 aMCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE); /* configure the clock for receiver */1 p# X' P) `4 Y6 s3 n
McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);
. u* P0 Q/ n, W: i; n* Z$ C0 YMcASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE); . C1 [/ K; C8 V1 u* N- e- u
McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,
) Q7 \% L3 k$ p1 F7 c/ z0x00, 0xFF); /* configure the clock for transmitter */6 x+ B7 |& d+ x
McASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);
" y y# ~+ @( C. P8 v% u& r; QMcASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE); 6 q4 @. K6 K: C& h7 r1 T; ]
McASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,
" Z5 R* [' h, v) n% d0x00, 0xFF);
6 m" x3 ~+ W3 Y( i+ ?& q! u" G* i& P9 r* g% d- O- [
/* Enable synchronization of RX and TX sections */
8 i# A( P% d: DMcASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS); /* Enable the transmitter/receiver slots. I2S uses 2 slots */7 ]- J; G k7 g
McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
2 }% f2 q$ S) \. ^7 W9 r1 OMcASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); /*4 w) b0 n* H- |' T9 f8 }
** Set the serializers, Currently only one serializer is set as( g! Q- G! s B% ?4 a, \- a
** transmitter and one serializer as receiver.. C' m# s& [9 S( N9 Z& D' D# i
*/
- q9 A' n' B- ~4 B0 }McASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
5 Y6 D# L. f7 {( Q/ u# \' c2 LMcASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX); /*
. \$ Z* \6 v, U2 V4 x5 R( J** Configure the McASP pins * w. `- H2 U' t4 |% z, e5 w9 y* X
** Input - Frame Sync, Clock and Serializer Rx
+ V# e8 r6 [, R# [% Q+ q$ D; T0 B** Output - Serializer Tx is connected to the input of the codec . W* L, S# T7 f. y* O: L$ n* n
*/
0 `; Z% D) ~3 C+ eMcASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);3 j: E0 X; O# N: Y0 M, _# c) B" w
McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));
2 m3 O- m7 x. y) ^2 F4 m7 L: LMcASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX
2 h2 v& [& H5 U' M- q| MCASP_PIN_ACLKX
) F: e2 B V% Z. ]5 O| MCASP_PIN_AHCLKX
/ U- o7 k, V D9 l: }| MCASP_PIN_AXR(MCASP_XSER_RX)); /* Enable error interrupts for McASP */
( @8 h& Y3 i: }- z% A0 TMcASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR
; P! j) }& i: V2 L$ L| MCASP_TX_CLKFAIL + ~. |$ O. k$ Q4 G
| MCASP_TX_SYNCERROR
" s2 N) V( J. {( n' o| MCASP_TX_UNDERRUN); McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR 8 v9 D( l/ P3 S2 u% E; [
| MCASP_RX_CLKFAIL
: F8 p) q0 \' F' H$ b! w7 e| MCASP_RX_SYNCERROR
4 f( v( Y |7 p( z/ @| MCASP_RX_OVERRUN);. w" L. N( P+ F; O/ J( P
} static void I2SDataTxRxActivate(void)
7 T& r V. _3 s3 d$ w{( l9 w6 P- Y3 h* x- B, U& P
/* Start the clocks */
) c' f' C3 ?: e. ~3 e. o' v _McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);
7 `3 }: A1 ]! KMcASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL); /* Enable EDMA for the transfer */
) G; |; w7 w% @) O" eEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,7 _5 ~1 j' {; B- R- X" _7 T) |& _
EDMA3_TRIG_MODE_EVENT);
& E" p+ X+ _. c; S7 j" R0 AEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS,
& @1 C7 X" i$ r; V) Z, _* `EDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT); /* Activate the serializers */: }! m2 ^* i* c/ }# @6 P
McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);- a; l) X" @0 X1 y9 ^+ x
McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS); /* make sure that the XDATA bit is cleared to zero */! W7 O$ S7 _/ a2 P5 c: r, e( v. f
while(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY); /* Activate the state machines */' B, L- d4 I% B+ l4 H
McASPRxEnable(SOC_MCASP_0_CTRL_REGS);
/ W& v# e2 Q4 V4 A1 e: UMcASPTxEnable(SOC_MCASP_0_CTRL_REGS);
$ x9 ^1 Q6 `# @' O9 K, R, e}
% s: y/ x: p3 O3 |请问:问题出在哪了,时钟按照这样配是否有错。 另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0.
) p4 x2 v* y% S9 n% c |