嵌入式开发者社区
标题: MCASP自环配置。 [打印本页]
作者: wapdasta 时间: 2018-11-7 13:28
标题: MCASP自环配置。
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。
部分代码如下
input mcasp_afsx,
4 Z% ^+ Z: c! a9 N y0 Uinput mcasp_ahclkx,& `8 k$ x0 k. [
input mcasp_aclkx,- ~1 | W& s# y& L
input axr0,
( [/ n" Q# ^6 g3 X' X# d; \( v+ u7 o6 f5 \
output mcasp_afsr,) }0 ^: }/ K; A
output mcasp_ahclkr,
& r- ^5 L% M% koutput mcasp_aclkr,4 W; s% v B9 |) F& V
output axr1,) g; n6 K$ o% W9 h
assign mcasp_afsr = mcasp_afsx;3 Y; b, ]& O0 w
assign mcasp_aclkr = mcasp_aclkx;( |1 K& \* v: n1 |5 R
assign mcasp_ahclkr = mcasp_ahclkx;
) m6 z5 ~" Z1 B: R& c1 Cassign axr1 = axr0;
% L7 ~- Y! G0 Y' [& r
! |+ K3 S" Q: i+ J. M/ S3 p- N在OMAPL138这端,通过axr0接口发固定的数,axr1接收。
在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。
一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。
部分代码如下,关于edma3的部分未做变化。
* ~& F0 N0 i+ r" h! _. d7 {+ j
static void McASPI2SConfigure(void)1 w, F5 G, F; u% N
{
# ]/ @& S \# ?McASPRxReset(SOC_MCASP_0_CTRL_REGS);
$ X7 [: n6 G& u, P& OMcASPTxReset(SOC_MCASP_0_CTRL_REGS);
/* Enable the FIFOs for DMA transfer */" O" u$ j3 b8 M/ ^
McASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);+ G& B. x0 w: [) X! q
McASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
/* Set I2S format in the transmitter/receiver format units */
" Q8 x% L5 y+ Q" ZMcASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
' ?% R7 k( f1 k" q) vMCASP_RX_MODE_DMA);5 }' v! m! d8 \
McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,* |6 b6 @$ y+ m* X8 j$ `, p
MCASP_TX_MODE_DMA);
/* Configure the frame sync. I2S shall work in TDM format with 2 slots */
6 V0 i: l# I# @6 iMcASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, + O* d% q' q Y; q: x4 T
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);
/ j, M8 [, e3 W! Q0 XMcASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD, : D- l5 K1 B. i' [% D( {
MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE);
/* configure the clock for receiver */8 E1 h% Z* E; x- s" C0 O: l& N
McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);1 n5 f% `( k, S* R0 k
McASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE);
: j. h P1 Y9 @: }+ V, HMcASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,
6 b9 R+ m6 X# B+ a! E0x00, 0xFF);
/* configure the clock for transmitter */ X( f% q) U9 ^& K
McASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);$ _6 e( `; o7 A4 U/ B' r
McASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
' l9 N0 `# r% }6 F' z1 ?- Z! WMcASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,+ W: t7 X+ R" {7 X% \
0x00, 0xFF);
$ ^5 M% B0 O! A. j
l; R" w0 x/ ?1 l) R' f( I/* Enable synchronization of RX and TX sections */
+ v( F( n4 D1 ~* z( D; s3 pMcASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS);
/* Enable the transmitter/receiver slots. I2S uses 2 slots */
. Y- o# ?' g. [5 M9 q9 J9 |5 L7 ]& jMcASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);- }* w7 h s; w' X* V/ S9 ?) u
McASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
/*3 h( h* E8 i& w8 i/ g
** Set the serializers, Currently only one serializer is set as* i6 A" T3 z$ e
** transmitter and one serializer as receiver.
, {+ z6 g" X; M9 Z0 ^ s*/
9 ]7 T) i* S! {" N- D8 iMcASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
4 D k. Z. M. F4 f, ~McASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX);
/*
: m; _( c& X% t5 y$ {** Configure the McASP pins ( P3 i9 A! W: |% q% V" k
** Input - Frame Sync, Clock and Serializer Rx
* `: f$ x6 Q7 @& L! ^* Z& T** Output - Serializer Tx is connected to the input of the codec
" `4 J$ p2 l, E0 Q x2 G8 F*/# h K% U5 s. l
McASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);% L, P& L& u4 V
McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));8 R b$ _6 w0 N7 E5 \, z
McASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX
6 @3 S, B z/ @1 h) V) T8 || MCASP_PIN_ACLKX
( w6 X: s5 R8 ?6 }1 H| MCASP_PIN_AHCLKX1 f8 F5 x* c8 N$ n' r& ]& g
| MCASP_PIN_AXR(MCASP_XSER_RX));
/* Enable error interrupts for McASP */
6 c5 _$ {+ l$ r% |McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR 3 U# J( h6 n$ O* p% V1 H3 Y
| MCASP_TX_CLKFAIL
) j# E. W7 m. G: g( c5 i* {| MCASP_TX_SYNCERROR8 g2 V0 u1 d. l+ W* C3 c6 B W
| MCASP_TX_UNDERRUN);
McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR
0 m$ R8 i) L" ^: Z: W1 K: d| MCASP_RX_CLKFAIL
' p$ h$ C& m2 q6 [9 ]' Y9 w| MCASP_RX_SYNCERROR
/ `) U- d. f$ `5 C/ N0 U1 B2 F| MCASP_RX_OVERRUN);4 y2 n* i( q5 `' w! r, m* ?
}
static void I2SDataTxRxActivate(void)
6 V& ~. m1 H x' o1 {7 u' X: a' h5 Y{
/ T! | ]# ?4 p5 a' M) t1 [: C/* Start the clocks */9 b. w9 C. [- `) ]
McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);
0 a7 ` i8 n+ i" [- NMcASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL);
/* Enable EDMA for the transfer */% g" R5 k# s# i+ B; W7 [/ m
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,- e% t I4 o1 Y; V+ a r! g
EDMA3_TRIG_MODE_EVENT);
$ M" s; V9 S3 L$ `EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, ! G5 Y/ ]1 }$ A' h$ S% S) J4 }
EDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT);
/* Activate the serializers */
* h$ a3 a' B* v0 P7 G8 wMcASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);
- J, A: i. x( ?McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS);
/* make sure that the XDATA bit is cleared to zero */+ j6 g/ m9 n) w5 A1 _
while(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY);
/* Activate the state machines */. u' W# f; {# Y, Q8 z
McASPRxEnable(SOC_MCASP_0_CTRL_REGS);/ c2 o0 ]& c" B1 m' ?8 P7 ^) ?
McASPTxEnable(SOC_MCASP_0_CTRL_REGS);
; T9 u9 E6 a$ R$ I3 v& c8 J8 z2 y: v}
; U6 b7 m5 ~4 ^# d t
请问:问题出在哪了,时钟按照这样配是否有错。
另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0.
* e4 o; c2 i9 Q; z) D. S
| 欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) |
Powered by Discuz! X3.4 |