|
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。 部分代码如下 input mcasp_afsx,
6 S, G$ ^# R1 v4 rinput mcasp_ahclkx,( ]" o6 P$ @ g
input mcasp_aclkx, P" @% a8 g% a) j% ~- f+ y
input axr0,
9 `1 |2 A- h. B( U' E9 I; m- P5 C& N4 A
output mcasp_afsr,
0 ?; s0 P' W2 \' Woutput mcasp_ahclkr,& {; W* W' j& |' e: U& P4 w# y
output mcasp_aclkr,4 e3 G7 J+ d2 {0 p+ L. K* \0 O
output axr1,# c" k* c* F% p# Y0 f( b
assign mcasp_afsr = mcasp_afsx;
- V8 K3 D8 w. X) X: U' wassign mcasp_aclkr = mcasp_aclkx;; {; C# l3 B* a( x. p7 o: Q# _
assign mcasp_ahclkr = mcasp_ahclkx;4 b7 [- m! }/ W; ?$ o
assign axr1 = axr0;
& n" i' B3 d& B# l
8 r' P. F& P6 i& u# l4 ~在OMAPL138这端,通过axr0接口发固定的数,axr1接收。 在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。 一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。 部分代码如下,关于edma3的部分未做变化。
& ?6 ?3 q& l( B; Kstatic void McASPI2SConfigure(void)4 Y7 t+ n4 y% ]+ Q& p% h
{
$ u8 X: @& N9 G. H, V: nMcASPRxReset(SOC_MCASP_0_CTRL_REGS);: v: I0 [0 v' q/ ?0 @9 f0 u- q
McASPTxReset(SOC_MCASP_0_CTRL_REGS); /* Enable the FIFOs for DMA transfer */+ I/ k* I& G0 Q7 @, P
McASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);. i3 n+ r8 a$ x6 z
McASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1); /* Set I2S format in the transmitter/receiver format units */6 y! o5 f- P( ?% R
McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,5 ]0 f$ X& r# u4 B. H- R2 O. f* J4 @
MCASP_RX_MODE_DMA);# ^% n: z! O3 l; ?/ [0 |4 Y1 D
McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
8 E9 z0 P0 g0 ]/ ~# w5 PMCASP_TX_MODE_DMA); /* Configure the frame sync. I2S shall work in TDM format with 2 slots */. ]* M% R8 `: A; a8 K# [" w* K% h
McASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, " l4 d: D/ r+ o8 w
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);
% n. G/ E" _3 }7 aMcASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD, 7 I' U0 o8 U4 C; q
MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE); /* configure the clock for receiver */4 ^$ }+ w/ Y9 ~) M
McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);
* [' T# S }. f& _; [, a- o1 aMcASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE);
7 |, _+ K, T/ w+ nMcASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,$ j; A& Z8 X% a( B
0x00, 0xFF); /* configure the clock for transmitter */
1 C5 ^! e4 k# E9 }McASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);
- v, U4 ?/ O, _2 CMcASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE); , ~- z* t" w' e) ^. p. f1 t1 s! r
McASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,* s1 c; P" Z/ P0 r6 O
0x00, 0xFF);* w$ d/ ?5 P+ j" \; }. I( v
4 F# v" e4 u. \# V/* Enable synchronization of RX and TX sections */
% r3 T6 w. S: L3 VMcASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS); /* Enable the transmitter/receiver slots. I2S uses 2 slots */
8 o/ `% s& I5 ~7 a; O. IMcASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
5 M! l; |$ s% B7 H7 Z& w1 {McASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); /*; F! v- w4 M) C5 }, g( @8 W
** Set the serializers, Currently only one serializer is set as
m# L! K/ N% y** transmitter and one serializer as receiver.
6 X2 L9 o/ y, r. [. K*/; H# h7 Z3 @& P. o X/ m
McASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
" l: {1 y; h% a* K; }0 u2 UMcASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX); /*
( {: P/ B1 l$ Q$ l** Configure the McASP pins
& }5 S8 W! w; a' @8 y** Input - Frame Sync, Clock and Serializer Rx
6 w6 N3 U" T8 t** Output - Serializer Tx is connected to the input of the codec
. x- a0 ~4 s! u7 m9 @1 u*/
F% e8 j( P7 y) K% O9 ^4 u: ~+ u/ @McASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);
# l4 ~" a; ^$ i, P2 i% LMcASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));
) C; F; |. B6 S! Y* B. lMcASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX
0 ~ p4 i Z2 k* s5 U# ^! z| MCASP_PIN_ACLKX
! z) k- ]4 e, n+ n, S+ u2 |' s& j| MCASP_PIN_AHCLKX
( _8 |* F/ ]4 H| MCASP_PIN_AXR(MCASP_XSER_RX)); /* Enable error interrupts for McASP */) l* u" A2 ]- g" ]
McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR 1 C/ t6 F* t+ c- J- x4 g: b, _/ P
| MCASP_TX_CLKFAIL
: A- o; }+ l5 @% H| MCASP_TX_SYNCERROR( D% H5 ~( c5 ?, U/ K" _
| MCASP_TX_UNDERRUN); McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR
7 p% [- n* p! c" y* u b| MCASP_RX_CLKFAIL
/ G; L, z6 g, ^# y5 I& a| MCASP_RX_SYNCERROR
9 L. l1 v0 B3 n# V1 f2 k% n8 h| MCASP_RX_OVERRUN);7 `2 w- d7 @! |" L
} static void I2SDataTxRxActivate(void)
# {& }+ k, G! U+ s3 {{) w$ ` f4 ~: c3 P& s, l7 [
/* Start the clocks */, |1 z3 d8 ^$ c/ S
McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);& w# V: U. C- r7 r
McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL); /* Enable EDMA for the transfer */% k, B# k' Q& L/ J# n$ }% G
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,
% T5 a* i8 O7 e2 b$ h6 H }EDMA3_TRIG_MODE_EVENT);! T/ I) n: C) |3 j# |9 @, ]8 Y
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, 6 s' Y/ ~5 G: ]% A/ K
EDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT); /* Activate the serializers */7 \/ E) a6 v! H9 Z
McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);5 Y! |. n6 z: ^# ^0 S. C, @
McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS); /* make sure that the XDATA bit is cleared to zero */
7 e6 B: i3 d: h' u; @8 s) twhile(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY); /* Activate the state machines */. e4 t/ Z6 I I3 Q) M1 m% k" n1 W; I
McASPRxEnable(SOC_MCASP_0_CTRL_REGS);% M1 J- y( C- s' Z5 Y
McASPTxEnable(SOC_MCASP_0_CTRL_REGS);
7 d% F2 H$ r6 b7 S} . y8 j) a- s- h8 `* z
请问:问题出在哪了,时钟按照这样配是否有错。 另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0. 1 U3 u% ?' F% h
|