|
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。 部分代码如下 input mcasp_afsx, a. h: _& K+ w% @5 R
input mcasp_ahclkx,8 u3 c% S* `% w2 C1 K
input mcasp_aclkx,
' j5 G# F, t z6 L' m4 z! o" xinput axr0,& u. Z0 J* ^7 x! J( P
1 ]' W$ k4 P% B; Soutput mcasp_afsr, {, Z4 w0 w$ [
output mcasp_ahclkr,
# [6 k |1 `4 T% youtput mcasp_aclkr, K9 m4 \$ X- r4 Y6 y7 S i( F0 f
output axr1,
4 w7 z7 H2 e# A& J- V6 O" Z assign mcasp_afsr = mcasp_afsx;
2 E+ h7 G" Z( ~# V* i/ F f7 V9 Xassign mcasp_aclkr = mcasp_aclkx;, @* C& ?: G0 b: B, n
assign mcasp_ahclkr = mcasp_ahclkx;
% z9 @! o( Z5 ^2 o8 l' Lassign axr1 = axr0;
2 z* x% @/ G" s3 B0 D% E7 W
# F$ F; T" @& y在OMAPL138这端,通过axr0接口发固定的数,axr1接收。 在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。 一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。 部分代码如下,关于edma3的部分未做变化。 ; B& S; u' k( ]: L+ l1 Q: {/ X8 g
static void McASPI2SConfigure(void)
l7 i9 o; t0 ]% V+ z( t. t{0 h7 x* ~0 J" X% m
McASPRxReset(SOC_MCASP_0_CTRL_REGS);
7 v1 P9 o- A& ?, y2 Q" B1 VMcASPTxReset(SOC_MCASP_0_CTRL_REGS); /* Enable the FIFOs for DMA transfer */3 ~8 ^3 k$ o% V( S+ l1 @: q- W9 o
McASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
& a# ?% [4 Q. f. i2 T0 wMcASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1); /* Set I2S format in the transmitter/receiver format units */
8 H" V: }, B6 {McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,! U' z4 b# n" A9 s* d/ j/ E
MCASP_RX_MODE_DMA);5 R' U. Z G' G2 Z
McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,. q' z$ ^* y/ X4 h
MCASP_TX_MODE_DMA); /* Configure the frame sync. I2S shall work in TDM format with 2 slots */
: r- z$ S# f& C! u- ^) f( `0 oMcASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD,
: |1 O5 Y6 r0 _' UMCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);
; z6 _/ L0 p; c- ~6 CMcASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD, " L% D6 C; E) ]' I( J: g
MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE); /* configure the clock for receiver */; \2 h. }8 t1 V
McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);
; S- Y+ R! N B( n1 i5 J* VMcASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE);
# u9 _& N9 H) R% r4 z. I' G. tMcASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,
+ U6 p$ t$ B7 N2 U! f" x" u# T0x00, 0xFF); /* configure the clock for transmitter */+ Y, ^9 I0 {6 B; `0 K+ s) P2 _
McASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);, r$ ?2 ^* F( e
McASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
: t; z! B; l0 G+ E n/ W/ Y4 g RMcASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,: `/ m- ]% O& |# }* b1 U8 q0 K, _. v
0x00, 0xFF); e4 ~% [- h4 g- `- ~; c
6 Y, G+ r0 w2 D! P% Q2 K. C
/* Enable synchronization of RX and TX sections */ + e g3 H6 j, @. r' |9 B: K* m
McASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS); /* Enable the transmitter/receiver slots. I2S uses 2 slots */0 S, K/ |" I% t. i, k) s
McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);% l, p0 V$ {; b3 z7 W+ `7 U
McASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); /*
9 V: j% t5 I4 m# x** Set the serializers, Currently only one serializer is set as6 D, S# U- ]% q! U' X
** transmitter and one serializer as receiver.
- Q7 X# T* Y# r2 A*/
( q; w6 n, i& X) U/ ~; ?; SMcASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
& t7 K6 m# l9 o' |6 m) A8 |McASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX); /*+ I6 }$ I8 V- B* g- B+ R6 s
** Configure the McASP pins
: C6 ~2 G- j# B$ n2 J" |** Input - Frame Sync, Clock and Serializer Rx6 l+ s7 t4 D) d
** Output - Serializer Tx is connected to the input of the codec
. p; i! J! r" _3 Y*/
8 M9 s" `2 i# @7 u! f% i& i# qMcASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);2 h2 Y/ G2 [9 F4 g& y* \
McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));
; _4 b* G. k1 N/ C" n+ bMcASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX
; Y5 d) n' q) F s! E| MCASP_PIN_ACLKX' D1 z+ {( f: O
| MCASP_PIN_AHCLKX
. c" p5 Q) K: t7 D; s9 K| MCASP_PIN_AXR(MCASP_XSER_RX)); /* Enable error interrupts for McASP */
% X6 \$ j4 X8 v; i6 C0 nMcASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR
- b/ E+ t2 V# l U& c2 D6 Q| MCASP_TX_CLKFAIL 7 V. S$ o+ F% o# C1 D& I9 Y
| MCASP_TX_SYNCERROR
+ D" B/ {7 B* D' X5 d: ]| MCASP_TX_UNDERRUN); McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR ' g: q% N+ q: h( C" d8 _2 I% N
| MCASP_RX_CLKFAIL
6 X- j7 w, f- O| MCASP_RX_SYNCERROR , A0 I9 O1 M; i. G* k
| MCASP_RX_OVERRUN);* Q9 ]7 c1 f7 I, t
} static void I2SDataTxRxActivate(void), X- o# N1 [; A/ W3 o- m
{
& J ^, g! ^' X/ e" {0 ^/* Start the clocks */9 C+ h4 s; j4 X& M( R; ?
McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);3 X" J4 c# h# t0 F6 F0 |
McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL); /* Enable EDMA for the transfer */
! _, i: ]% A0 f7 UEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,
# H" D' |, O4 B# m8 Q0 N& \0 mEDMA3_TRIG_MODE_EVENT);
; j/ s* o) _. W% W6 |EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, * C }; n8 k2 K7 o$ x
EDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT); /* Activate the serializers */
5 f, g) d" o2 Y, f8 L; K% jMcASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);& W' l1 j2 N. F+ s0 q. E w
McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS); /* make sure that the XDATA bit is cleared to zero */! V, f5 G) `! U% e5 n. m" r. D- p" }
while(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY); /* Activate the state machines */
% k+ Q+ J# ^( T; rMcASPRxEnable(SOC_MCASP_0_CTRL_REGS);
3 N3 A" c5 }' j, D' JMcASPTxEnable(SOC_MCASP_0_CTRL_REGS);- D" I: M4 P) }0 {
} * f7 s( E0 C( Y4 S
请问:问题出在哪了,时钟按照这样配是否有错。 另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0.
% z+ Y- F) _) C6 V- W7 e |