|
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。 部分代码如下 input mcasp_afsx,8 D9 M6 o: A% V
input mcasp_ahclkx,
! e7 d$ a1 Q: t' f0 @' yinput mcasp_aclkx, I! Y7 X9 l+ F! p/ P
input axr0,
, p1 g( v+ w; X5 V
5 p8 B6 a9 {8 z9 K8 q! I6 f: qoutput mcasp_afsr,
8 }' C, T" M+ I$ j5 Youtput mcasp_ahclkr,& N! v9 e* P0 r0 B: K
output mcasp_aclkr,
0 K0 [' p3 `0 A. youtput axr1,* y' S) W( I! g, e4 x
assign mcasp_afsr = mcasp_afsx;
6 @! u5 D* |9 l% y4 J% z9 ^* Gassign mcasp_aclkr = mcasp_aclkx;
: K" _( C' H+ f4 f ^assign mcasp_ahclkr = mcasp_ahclkx;$ \/ Z G9 j4 t/ K: K+ M: b- [" J3 }
assign axr1 = axr0;
2 `3 l) p4 M2 z- x) g* [4 |* T" [4 `& { ~. t8 A- {% \
在OMAPL138这端,通过axr0接口发固定的数,axr1接收。 在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。 一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。 部分代码如下,关于edma3的部分未做变化。 5 N4 h6 P2 Z; E
static void McASPI2SConfigure(void)# r% X# i# q$ v& s
{
; o# V/ J' J1 D( R; o2 ]) G; eMcASPRxReset(SOC_MCASP_0_CTRL_REGS);+ M$ Z; L+ Y( k% Q
McASPTxReset(SOC_MCASP_0_CTRL_REGS); /* Enable the FIFOs for DMA transfer */
8 I7 i) l3 ~, k) [) ZMcASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);4 R4 q1 d+ E* ^/ S
McASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1); /* Set I2S format in the transmitter/receiver format units */
}0 L4 N/ U( V u# W$ |# PMcASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
- \9 l7 z9 Y( s/ z. ^MCASP_RX_MODE_DMA);/ @5 f1 w* J3 w7 S3 o& W
McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,8 V2 Y! [+ W7 A- O7 V, O
MCASP_TX_MODE_DMA); /* Configure the frame sync. I2S shall work in TDM format with 2 slots */# c- K+ O* L, ^0 x4 V
McASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD,
$ G$ A4 ?7 P6 @$ NMCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);: G J) \; v6 C' D: t
McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD, 9 W2 V @3 X/ z$ _7 f
MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE); /* configure the clock for receiver */
0 y5 h# e. |- b; N8 B! C k1 \McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);
, L5 ~3 Z% t' V1 s6 ]McASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE); 8 Z0 V8 o7 F0 z+ P2 |4 J( M
McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32, f! A: N9 ?, D
0x00, 0xFF); /* configure the clock for transmitter */" R, s. h7 s" z
McASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);+ ~2 U2 d; s# |% z" ^6 V3 i# f5 v
McASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
& T) ?6 m6 u5 W" A- g, b$ HMcASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,
9 a# \% D- K6 z1 E. [8 d0x00, 0xFF);
9 y% i; Y: E6 p/ O# k2 u: b! g8 O6 r0 a6 m: t
/* Enable synchronization of RX and TX sections */ , [5 y" Q z7 w; I' y2 P
McASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS); /* Enable the transmitter/receiver slots. I2S uses 2 slots */' G& @1 U0 W! }0 k8 g9 U9 X' X7 q
McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);* E% A' z; {' a! J
McASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); /*
4 `; X4 l1 `( S* K** Set the serializers, Currently only one serializer is set as
; Q) f2 a2 J: Q, H% ~0 x, L" h0 P0 I** transmitter and one serializer as receiver.
( e2 j5 y8 I# a8 X$ Q*/
( l2 x' S- C4 m( R1 f7 h+ T: M* x8 N5 ]& UMcASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
5 z# i& S& l6 c1 R7 e Z( x) P* qMcASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX); /*+ ^. j7 R" S8 v T% i
** Configure the McASP pins
- T6 _! y) u- X1 a** Input - Frame Sync, Clock and Serializer Rx9 |, I/ X! d7 _& C9 e1 g! p) _
** Output - Serializer Tx is connected to the input of the codec c( k% |$ @. M" o2 m) g
*/! b# A5 O. C, T
McASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);8 b; G7 {# F4 ^1 J' `' r
McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));2 v+ n+ _- L% a# R( S) {# P
McASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX
5 @1 n1 d8 G9 M+ N| MCASP_PIN_ACLKX! L7 k+ d9 b, `0 g! S# M8 a
| MCASP_PIN_AHCLKX2 Y4 s* f2 s, B! c( `% T, W
| MCASP_PIN_AXR(MCASP_XSER_RX)); /* Enable error interrupts for McASP */- u4 Q: U8 _3 z) f2 ?6 t
McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR ( E8 m: ~$ V8 D
| MCASP_TX_CLKFAIL
8 p1 M2 }$ i" _1 M n7 O' ^| MCASP_TX_SYNCERROR( f* }+ b/ q3 X4 a3 H
| MCASP_TX_UNDERRUN); McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR {! S1 i9 ^$ [! y
| MCASP_RX_CLKFAIL
. Z. L* e8 C, I| MCASP_RX_SYNCERROR 6 _# r1 H8 ]! T) L, c
| MCASP_RX_OVERRUN);
3 ^3 t! c( g0 Z) U" C* M. ]1 `} static void I2SDataTxRxActivate(void)
5 R5 n) _- d% U; l/ a{
9 m/ f- A- s& _9 d. N/* Start the clocks */
; C7 s' S' P6 F. P5 I+ EMcASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);
' t7 o) q7 a0 Y4 k2 xMcASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL); /* Enable EDMA for the transfer */
) r" L A2 @& I b7 ?EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,% ~! L+ m5 r/ b5 F# c
EDMA3_TRIG_MODE_EVENT);
* q! x1 N: F* F5 t& J7 k9 C( F4 fEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, 6 @3 b" W7 e) h2 H3 j$ W
EDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT); /* Activate the serializers */
( _# ?4 v7 }2 v5 X$ [McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);
6 r$ V- w; N* h& iMcASPTxSerActivate(SOC_MCASP_0_CTRL_REGS); /* make sure that the XDATA bit is cleared to zero */
- p2 C+ M1 a c: Wwhile(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY); /* Activate the state machines */
: i' [! W% Z2 d# k$ R6 X1 {+ j1 cMcASPRxEnable(SOC_MCASP_0_CTRL_REGS);3 C% t* v5 P* b& p: P& a
McASPTxEnable(SOC_MCASP_0_CTRL_REGS);$ H4 N; m! e# _9 \. L# }6 |) a4 V! C
} ! y- {( f* r& |- K( `
请问:问题出在哪了,时钟按照这样配是否有错。 另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0. $ q% |& f/ o! l
|