|
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。 部分代码如下 input mcasp_afsx,
6 D9 ?* s) t' N# B6 ginput mcasp_ahclkx,
- @ }5 a) G/ Q, K) A! b' Pinput mcasp_aclkx,8 `5 O* X4 i2 N% L
input axr0,
& K% ~; d! G$ N! ]) A! T$ m/ e
output mcasp_afsr,) z4 S5 b- u7 i$ T
output mcasp_ahclkr,
9 Y6 r* d' Q% K* ~0 Moutput mcasp_aclkr,
* L% L% Y$ w5 U3 joutput axr1,1 G# }# l: X9 m% V9 H1 V% a
assign mcasp_afsr = mcasp_afsx;. g6 b8 ?8 c+ G* c( j0 |
assign mcasp_aclkr = mcasp_aclkx;
6 G# C" O! i$ T# P+ f3 Zassign mcasp_ahclkr = mcasp_ahclkx;% b- h6 o$ d% f7 L: w- e+ [& D! ?9 }
assign axr1 = axr0; $ }" V- O! a9 M1 Y) N( T
+ r4 S9 a& x6 S7 J3 v: E4 q在OMAPL138这端,通过axr0接口发固定的数,axr1接收。 在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。 一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。 部分代码如下,关于edma3的部分未做变化。
l; r, s: P2 Q5 ?8 Rstatic void McASPI2SConfigure(void)" z& G& Q# A8 ~2 D: b
{7 U7 ]" V* s: y3 h. Y/ ?
McASPRxReset(SOC_MCASP_0_CTRL_REGS);
5 P$ [- p0 A1 aMcASPTxReset(SOC_MCASP_0_CTRL_REGS); /* Enable the FIFOs for DMA transfer */- y4 {" o3 k5 x4 j! |5 c
McASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
, \( u- P" l* LMcASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1); /* Set I2S format in the transmitter/receiver format units *// G: @' ^3 @1 ]% U1 x
McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
. }6 Z6 ]4 m& _1 oMCASP_RX_MODE_DMA);% I% F9 j3 n$ N, U+ r4 o2 m
McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
- d2 B& B5 u3 B( o) @MCASP_TX_MODE_DMA); /* Configure the frame sync. I2S shall work in TDM format with 2 slots */
y, a! @" V/ }. rMcASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, 1 X5 l1 u$ I4 b, ]9 l( r
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);! N, Y' X; W! J' t
McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD, ( i, M2 k5 c% ]: e+ m9 \
MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE); /* configure the clock for receiver */
* W8 u9 h2 X$ M; {; AMcASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);( \! a0 K% J/ z# G. v8 H* e
McASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE); t1 `. ?+ ]5 e3 _; z5 Z* {
McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32, p: E# Y! ~$ c# n
0x00, 0xFF); /* configure the clock for transmitter */! i$ O1 N: |+ U# W* s2 i
McASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);3 ?# \2 i* G1 N0 {) m8 e0 Z$ [
McASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
& ^1 X8 `& x. k0 p! ]McASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,
5 ?+ p! H# o R. b0 c, |0x00, 0xFF);
7 |; l8 ~+ g' l4 r( H5 P+ X* r& h& z+ A* `) \# z; B
/* Enable synchronization of RX and TX sections */
- \0 I9 @, u8 s' R' DMcASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS); /* Enable the transmitter/receiver slots. I2S uses 2 slots */ p2 M9 L8 x$ e' o
McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
) d$ H2 s2 I4 u9 f* r, TMcASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); /*
1 @, q( i6 b5 l' ]+ p8 R6 N2 Y6 d** Set the serializers, Currently only one serializer is set as/ n& ~& a6 T C# A9 C; T
** transmitter and one serializer as receiver. f: V- y1 K' J x
*/
* f0 ^2 b% h, j' A: X% E2 G* yMcASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
; P7 a, G) W8 B" f' LMcASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX); /*
+ K% s: {/ k# i* I8 R, z6 b" v# F** Configure the McASP pins : H# W, g8 w- i9 g' V! ]
** Input - Frame Sync, Clock and Serializer Rx# _7 J1 r5 t5 R
** Output - Serializer Tx is connected to the input of the codec * V4 B& s+ U2 P
*/
1 G; Q# d# ]. F& h2 d# f8 lMcASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);) A" g' b6 W, Q6 K
McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));
* x* X0 d! `6 u, ^McASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX
& {2 c0 ]5 ?. f& t/ C| MCASP_PIN_ACLKX
% V U# k V& ^7 F9 d# C/ w| MCASP_PIN_AHCLKX
- n* }8 P# \: `# ?: g| MCASP_PIN_AXR(MCASP_XSER_RX)); /* Enable error interrupts for McASP */
0 \3 e) V+ R) vMcASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR
a- n `" s. ?7 T% Q) m- l| MCASP_TX_CLKFAIL
% I1 d* F, d+ Q: f6 l% d% C8 _| MCASP_TX_SYNCERROR
% B$ Y6 h( i$ n$ m5 E| MCASP_TX_UNDERRUN); McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR : q8 F0 o* b; e: c/ q( D* Y
| MCASP_RX_CLKFAIL: @+ h+ x1 k' ~& o4 k
| MCASP_RX_SYNCERROR ; n K: K6 q. Z8 A
| MCASP_RX_OVERRUN);! i V: v! Q1 f0 p9 k
} static void I2SDataTxRxActivate(void)+ I5 z4 o" u# L+ V
{
4 \+ O0 o; M! G/* Start the clocks */
* ?; T* n+ m4 E4 CMcASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);
$ s2 H6 |" u9 A( {1 J% eMcASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL); /* Enable EDMA for the transfer */1 B! f( x0 V: B
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,2 v3 w6 _# u( ^7 |, x
EDMA3_TRIG_MODE_EVENT);2 s5 e% [2 q) a* }
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS,
. }. ?. e, i+ YEDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT); /* Activate the serializers */
% o, }0 B. j. \; G1 Y1 d bMcASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);) B) a; l3 a( T
McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS); /* make sure that the XDATA bit is cleared to zero */
. L( s* E! b" T v/ ]6 {! x; Dwhile(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY); /* Activate the state machines */. ?$ {: u8 V `; x2 \% \
McASPRxEnable(SOC_MCASP_0_CTRL_REGS);! m% ?+ P9 H( m1 e' a# j* s: i
McASPTxEnable(SOC_MCASP_0_CTRL_REGS);
$ E3 p8 L+ G! j+ P}
9 C& W' W7 C+ ~& `请问:问题出在哪了,时钟按照这样配是否有错。 另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0.
6 Z& ^ b. {- t4 u3 A |