嵌入式开发者社区
标题: MCASP自环配置。 [打印本页]
作者: wapdasta 时间: 2018-11-7 13:28
标题: MCASP自环配置。
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。
部分代码如下
input mcasp_afsx,
7 c n/ i- Q1 i# P7 M. Linput mcasp_ahclkx,/ B X0 l8 y V! q# K5 z
input mcasp_aclkx,
3 T# X6 O* l" E' @/ ninput axr0,
+ A9 ?. [& x* {9 c
% d6 K) V5 N" N' {, \+ E: Woutput mcasp_afsr,
5 g. q; J+ \3 \' x& K" routput mcasp_ahclkr,
& [8 w2 x; k: [) poutput mcasp_aclkr,6 H7 U4 K" j- D6 T: [" n
output axr1,
' f& `- m# ^& J( @/ |
assign mcasp_afsr = mcasp_afsx;9 u! V$ C2 j8 [
assign mcasp_aclkr = mcasp_aclkx;
/ ]8 f6 J* v* C& t- ~% Kassign mcasp_ahclkr = mcasp_ahclkx;
, {, `2 f3 r$ q9 L. c# B9 X3 V' [assign axr1 = axr0;
7 Z4 e! }! W. t5 s9 l; n; A
8 u4 T& y/ z5 y+ I( D- F在OMAPL138这端,通过axr0接口发固定的数,axr1接收。
在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。
一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。
部分代码如下,关于edma3的部分未做变化。
& Q9 q: b! a& w4 H
static void McASPI2SConfigure(void), Z7 R& k- \% u2 H) w& b3 |: d
{
9 \/ y$ b# L2 {McASPRxReset(SOC_MCASP_0_CTRL_REGS);1 ]0 `- v0 L+ k% g6 l8 `" s" h
McASPTxReset(SOC_MCASP_0_CTRL_REGS);
/* Enable the FIFOs for DMA transfer */
+ O4 `: d' z; h1 u0 OMcASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);- Z$ h& B0 Q/ i' ?' L4 i) i
McASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
/* Set I2S format in the transmitter/receiver format units */: k4 a: k. c3 f
McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,, m# i( u: \7 q' `: b1 H
MCASP_RX_MODE_DMA);# `0 J/ f, f8 M# s# R4 y( A2 H2 J+ Y% o, ~
McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
, o+ @/ w& E: O6 t4 Y8 l: ?MCASP_TX_MODE_DMA);
/* Configure the frame sync. I2S shall work in TDM format with 2 slots */
. C6 c- X% a( c/ v4 xMcASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, ( V7 }( W# c! l/ B- V! u6 e
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);
; J/ J, `7 e; x9 s* k) ?McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD,
5 j( R b8 Z5 Y6 ^MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE);
/* configure the clock for receiver */& O: @% z+ U1 X0 }
McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);& p- ~3 o0 X/ @! ~* g
McASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE); & Q2 {5 W5 L. W" f g- i$ D
McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,
( I0 k" Z) q) w3 N8 c0x00, 0xFF);
/* configure the clock for transmitter */
8 l0 B- j g+ e7 j5 e2 z+ B* WMcASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);
& p( c7 G0 s2 l2 DMcASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
H1 W5 V8 s) c- S6 Y/ B7 Z( g8 }1 DMcASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,# a& f2 c. i4 j6 s& L
0x00, 0xFF);
1 r0 y9 `. ]: z) Z0 X2 w; j/ W2 b
' ]* C$ W4 H3 l+ l/* Enable synchronization of RX and TX sections */
4 X* A& S* d+ S; w1 i7 ~+ EMcASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS);
/* Enable the transmitter/receiver slots. I2S uses 2 slots */* D }$ a7 o4 y) n9 W5 N: @& P. }( d6 q
McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
5 s" b2 R' y+ P$ |( N! U2 QMcASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
/*3 S3 J0 B, @! @) e$ E
** Set the serializers, Currently only one serializer is set as- H0 p& d, l# j, c" z" N* N! Z
** transmitter and one serializer as receiver.! M% P5 v- z) e }) d
*/- O$ k# p+ ~/ w
McASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);4 J1 S1 j& j. x6 p( k0 }7 r% @6 N) Z
McASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX);
/*8 K$ l; T& }5 T3 `! R& `5 j* u9 @7 E
** Configure the McASP pins
/ l; E, ~1 \! a9 T) e8 h$ A& g** Input - Frame Sync, Clock and Serializer Rx4 r7 ` F! X5 J: L- O5 Q! i3 O6 C
** Output - Serializer Tx is connected to the input of the codec ; x; I2 n" N1 R
*/& H9 O) L$ c: q7 Y: r8 t
McASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);
3 J: p8 M% i" F: B/ ~4 ]$ OMcASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));$ Q, ^! X' j1 {1 j2 B
McASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX6 C. y! }4 _+ p! K
| MCASP_PIN_ACLKX8 Y6 P9 D* y, j7 Q) W9 u
| MCASP_PIN_AHCLKX" L( V# O+ ?* U" T5 p5 B
| MCASP_PIN_AXR(MCASP_XSER_RX));
/* Enable error interrupts for McASP */1 J, h' }+ g5 n# ?% x1 A( V' ?
McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR ( Q8 A5 F; _3 G( C O# Y& n( z
| MCASP_TX_CLKFAIL : O m: w/ Q+ L$ ?
| MCASP_TX_SYNCERROR3 O# B5 ~* z) m* U
| MCASP_TX_UNDERRUN);
McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR * h) b, i) d1 X7 Y& |9 S0 z
| MCASP_RX_CLKFAIL6 r# Z( Y( h; S1 e* `1 Z8 `. g5 V
| MCASP_RX_SYNCERROR $ s$ ?$ w# I- {0 F: o
| MCASP_RX_OVERRUN);1 C" e9 d$ J5 Z. M
}
static void I2SDataTxRxActivate(void)+ [6 r, y' ?7 E- L% X) a" w9 r
{
$ H" U4 A) c8 Z; w/ E/* Start the clocks */" Y1 m) V( P" H7 u$ {- D
McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);( q$ s$ l+ m7 e% C. o9 q
McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL);
/* Enable EDMA for the transfer */& z( @/ \5 N' o2 L2 |( U9 y
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,9 J' }6 U$ c& Z0 m" \7 l" b
EDMA3_TRIG_MODE_EVENT);
1 e& ~. J7 ~7 {1 }3 c4 P& ?EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS,
# m3 @3 I' U: B! O. pEDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT);
/* Activate the serializers */$ x P; h" l* b/ W' V0 n- D
McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);
6 S8 a9 t5 H3 I' S2 K- BMcASPTxSerActivate(SOC_MCASP_0_CTRL_REGS);
/* make sure that the XDATA bit is cleared to zero */
( F( m0 q( j6 [: Swhile(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY);
/* Activate the state machines */0 i/ ^/ }9 q0 n3 [' T! q, K
McASPRxEnable(SOC_MCASP_0_CTRL_REGS);
! @- M( x$ u" C/ t* tMcASPTxEnable(SOC_MCASP_0_CTRL_REGS);
/ g* m3 w* S6 P. I}
6 z. M( X8 b" `* u9 a$ C5 W
请问:问题出在哪了,时钟按照这样配是否有错。
另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0.
" @2 ^5 n x9 W
| 欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) |
Powered by Discuz! X3.4 |