嵌入式开发者社区
标题: MCASP自环配置。 [打印本页]
作者: wapdasta 时间: 2018-11-7 13:28
标题: MCASP自环配置。
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。
部分代码如下
input mcasp_afsx,
- d! X x( b2 {) kinput mcasp_ahclkx,
$ d. x- u9 Y3 ~input mcasp_aclkx,
0 C8 a; J2 @% }% V- K$ H) b# Ainput axr0,, K" E7 K/ c' n8 ~
5 @! I% ~0 k5 M5 E5 ]output mcasp_afsr,7 z0 V# i- P) `- U7 B4 z& w' ~
output mcasp_ahclkr,
* [* R4 P/ D, N8 @" O% @output mcasp_aclkr,. y) @% B4 r7 `3 t
output axr1,
( S$ w7 g6 D' x4 D' H& W: T4 L
assign mcasp_afsr = mcasp_afsx;$ b* {, a/ q) ^8 Q" F/ w- e
assign mcasp_aclkr = mcasp_aclkx;
" g& B; O& ?& N% }& Oassign mcasp_ahclkr = mcasp_ahclkx;
% A7 `( V3 W# U# U4 Z$ X6 massign axr1 = axr0;
/ J: Z& X% d5 s2 @# q& F
7 ^1 w6 f7 G" o/ t在OMAPL138这端,通过axr0接口发固定的数,axr1接收。
在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。
一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。
部分代码如下,关于edma3的部分未做变化。
) }8 }. ?# Y' ?3 astatic void McASPI2SConfigure(void)
- a) i3 t" w+ K3 x1 i8 Y: A{
- y l6 ?# z+ K+ ~( ? oMcASPRxReset(SOC_MCASP_0_CTRL_REGS);
1 R. z+ v8 c# Z3 V& W- L% lMcASPTxReset(SOC_MCASP_0_CTRL_REGS);
/* Enable the FIFOs for DMA transfer */
0 q6 _1 u2 f: ^$ JMcASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
/ c: j# @( ^3 w, S/ q Y1 }: YMcASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
/* Set I2S format in the transmitter/receiver format units */
4 M, C* \! Q% S9 wMcASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,7 g! B. e1 D6 B
MCASP_RX_MODE_DMA);
/ H& D0 A9 M T( G! mMcASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
+ |% D( A) l# R) R# WMCASP_TX_MODE_DMA);
/* Configure the frame sync. I2S shall work in TDM format with 2 slots */" {3 {* N& ?8 F/ J. S
McASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD,
0 \. `0 ?. g3 A0 I- m' B5 M' M, AMCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);
8 e* i; E1 a |2 c, `McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD,
3 u% m# c/ k# ]% Z( UMCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE);
/* configure the clock for receiver */- t5 y; ]7 ?( I q/ o8 \; ?( w& f
McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);
- H% ~ R. j2 EMcASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE);
7 h4 {& Q0 l& BMcASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,
! m7 r7 O7 C' {9 g; E& O# N0x00, 0xFF);
/* configure the clock for transmitter */
" ]5 b' |7 m, |- ~0 F4 IMcASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);$ h/ T- ?% }/ \! ]: |
McASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE); ( }5 X' u* g$ L! f" V1 s& P/ b
McASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,& I. T+ u" F4 t4 {
0x00, 0xFF);$ ^ p; O7 W# P" t4 S. X/ H
f6 F4 A- F# T- n9 N- [/ F% o6 N/* Enable synchronization of RX and TX sections */
, o! o1 g& o9 }( v5 o8 w0 o! M0 GMcASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS);
/* Enable the transmitter/receiver slots. I2S uses 2 slots */) }. J" L1 [4 L" Y
McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);# r, A8 ]9 n' S5 H; G
McASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
/*/ |2 D* l& K+ c5 `8 a4 ]. H6 [
** Set the serializers, Currently only one serializer is set as
5 C9 D6 Q; K) O9 @ Z$ y** transmitter and one serializer as receiver.1 f$ r# b. u$ z: F' Z( z$ u
*/7 {5 _ c3 }5 [6 K- u: u
McASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);( R, o% j' P2 C7 c. V) Y$ |" H
McASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX);
/*
# q, Q* ?* d: j+ ?# f+ G+ f( K** Configure the McASP pins
! v7 k5 P+ u: e; u1 R" W** Input - Frame Sync, Clock and Serializer Rx
- j- C) E8 w: }+ Z* D1 y** Output - Serializer Tx is connected to the input of the codec ' b; L0 R8 ^6 i) _. r
*/
9 {+ N' e, Z. ^1 c3 [McASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);
8 J) @. ^$ p9 g) h: T6 }McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));
`- n8 s' }. yMcASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX3 e1 D1 o8 h5 X$ \4 d' Y
| MCASP_PIN_ACLKX; x# q3 s, M0 E0 P) |% n
| MCASP_PIN_AHCLKX( W4 l6 B u. c# E/ n" O
| MCASP_PIN_AXR(MCASP_XSER_RX));
/* Enable error interrupts for McASP */ l6 h5 @+ s, o7 m, |( i+ z; E
McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR . u; @5 g% N8 e0 }
| MCASP_TX_CLKFAIL : @7 K! M$ Z* j5 b3 P5 k
| MCASP_TX_SYNCERROR5 }- B" R7 f) S, q) V- y
| MCASP_TX_UNDERRUN);
McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR . h2 B( ^& o5 L, R) l- r9 i
| MCASP_RX_CLKFAIL7 i' v1 X# @, _ I1 T+ l" p
| MCASP_RX_SYNCERROR : a: b4 q( Y9 o$ j
| MCASP_RX_OVERRUN);
% j2 x" U! p! A* J. o}
static void I2SDataTxRxActivate(void)
6 W9 D2 x1 ^% ^3 z{
* S- l1 f' I! O/ m' U/* Start the clocks */: l1 W n I, @
McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);: z+ { M- e! i# u8 {3 O
McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL);
/* Enable EDMA for the transfer */
! B3 l/ K$ K; u5 jEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,
/ J/ m* g6 e4 tEDMA3_TRIG_MODE_EVENT);1 S# w. w) j& d. v4 M- q
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS,
; _; V5 P: Y+ Q |" x4 f( K% KEDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT);
/* Activate the serializers */
* Z1 P- ~0 c. K5 m$ n3 OMcASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);9 G$ K o" C! V: i4 s2 V6 Y
McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS);
/* make sure that the XDATA bit is cleared to zero */
9 q, l" A9 q9 k- s! p% h6 cwhile(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY);
/* Activate the state machines */
- a% g2 U) U3 h3 s4 z3 P8 [- XMcASPRxEnable(SOC_MCASP_0_CTRL_REGS);
( Y8 v3 Q! {7 [" f1 q. s0 kMcASPTxEnable(SOC_MCASP_0_CTRL_REGS);5 M$ J/ t |+ Z2 M, n# \
}
6 @' \; {5 U1 `% h' N" _" K请问:问题出在哪了,时钟按照这样配是否有错。
另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0.
( G0 y' ^" X8 _- L
| 欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) |
Powered by Discuz! X3.4 |