嵌入式开发者社区

标题: MCASP自环配置。 [打印本页]

作者: wapdasta    时间: 2018-11-7 13:28
标题: MCASP自环配置。
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。
部分代码如下
input mcasp_afsx,
; B% K2 x0 {9 v$ pinput mcasp_ahclkx,  k/ F; m1 L3 C& n0 n7 B( b$ y
input mcasp_aclkx,
& n. F' t  y8 d- k6 U5 T6 Uinput axr0,8 f$ t% J7 c# x) H$ w/ t# V
" P! X6 s, L, A- s
output mcasp_afsr,
5 N& o# C: P# k; k/ h* r, n) D8 joutput mcasp_ahclkr,9 R' |( f1 D: X8 U' W
output mcasp_aclkr,
5 Y: w: J4 q" H& R! j& Z6 Poutput axr1,4 {+ S6 ^. p* O- X7 M. R
assign mcasp_afsr = mcasp_afsx;
8 f& B" K3 B% j$ Eassign mcasp_aclkr = mcasp_aclkx;
  c3 [  h7 C; O* K: ?assign mcasp_ahclkr = mcasp_ahclkx;1 H5 |7 Q5 S( w4 Z
assign axr1 = axr0;

& v/ v. _7 h4 F+ M7 n" Y
' X( V# O6 ^2 g9 i8 M  G
在OMAPL138这端,通过axr0接口发固定的数,axr1接收。
在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。
一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。
部分代码如下,关于edma3的部分未做变化。

" a6 E  M( p5 M9 {1 ~! ]
static void McASPI2SConfigure(void)3 c1 @7 r" ?0 ]% n0 R
{1 R& E  p& z& M) h# W' B- J
McASPRxReset(SOC_MCASP_0_CTRL_REGS);
5 H) C$ l/ ~- i1 [+ \. bMcASPTxReset(SOC_MCASP_0_CTRL_REGS);
/* Enable the FIFOs for DMA transfer */$ j( A1 a$ K) C  z4 ?
McASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);0 U# d# Z! G3 c, z( @/ w  Z
McASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
/* Set I2S format in the transmitter/receiver format units */, Q2 z. Q. I& ^- U
McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
0 ^$ D! L+ E  \3 M, s6 DMCASP_RX_MODE_DMA);
# E* z' W+ v- v$ U* vMcASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
# {  m$ W% P/ VMCASP_TX_MODE_DMA);
/* Configure the frame sync. I2S shall work in TDM format with 2 slots */. m1 |& q( h: o
McASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, - l" y* \. T+ n+ q, w. c/ s
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);
1 c6 |) e# J/ e) m9 f1 aMcASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD,
* I: i% }+ \6 P& {: d* A' |9 b7 }$ OMCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE);
/* configure the clock for receiver */8 m: {1 e2 g/ u& l$ ^
McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);
% ^2 \/ |9 j# S) {5 qMcASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE);
# z3 z' f; M: C4 G- R5 `) AMcASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,' h& _( Q4 M5 ^6 b4 W$ E
0x00, 0xFF);
/* configure the clock for transmitter */% n! i1 o; K& j/ P" q% t+ n6 q7 o
McASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);+ t% M& |8 I  h3 j; s
McASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
  t4 ?- n, i. _' ~8 r8 kMcASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,$ b2 B! C1 [- n) `
0x00, 0xFF);% p# ^& z/ f0 U/ R) ~, E. q
2 }3 n/ {. O9 B" Y. p
/* Enable synchronization of RX and TX sections */ 9 E; ~; h. R: H6 o! ^3 {
McASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS);
/* Enable the transmitter/receiver slots. I2S uses 2 slots */6 x- q4 R: Y3 ?& Z4 z* t
McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);& R1 S1 o2 Y1 o2 o: V7 N' M9 y
McASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
/*0 @8 f0 |. v: C3 S8 }& c) o, X' V/ f8 j4 v
** Set the serializers, Currently only one serializer is set as
7 K3 q( d9 a1 E. T** transmitter and one serializer as receiver.
  a7 R, H/ z( P# {: j*/
. q# y9 f" U6 C: }$ L5 UMcASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);# e* i; n2 |: v% i1 o/ [
McASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX);
/*
# p3 r2 c* R  T** Configure the McASP pins
$ V" o% p- \3 t4 B  Y** Input - Frame Sync, Clock and Serializer Rx
! ~- ?2 H0 \3 [** Output - Serializer Tx is connected to the input of the codec " h* F5 i$ c7 y( J+ a' P. f
*/
& L  s, z! [+ U5 U' L% U5 j( KMcASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);* k/ q' t  F+ I9 q4 p1 `
McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));
( c* Z- X' i( v# i" L- t- uMcASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX
/ s2 k. J$ F. S/ j# z' H; W$ ]| MCASP_PIN_ACLKX0 m* B8 G2 a4 }  C4 M2 z7 J( }
| MCASP_PIN_AHCLKX
6 [# K" M* N( B' ^. x9 ?* Y& v% i| MCASP_PIN_AXR(MCASP_XSER_RX));
/* Enable error interrupts for McASP */' \) C9 O3 m6 f3 g& l. }
McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR 7 i% r/ k8 h* J/ H# K
| MCASP_TX_CLKFAIL
* z1 F& Z5 x, s6 R| MCASP_TX_SYNCERROR2 u, R5 j! J7 A! [
| MCASP_TX_UNDERRUN);
McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR   x* n- S3 U# ~
| MCASP_RX_CLKFAIL
+ c% r- {/ x/ w2 D1 S  ~7 C| MCASP_RX_SYNCERROR - d$ S( m8 T2 y% R- x: J
| MCASP_RX_OVERRUN);8 F& v6 D/ Z6 R  e
}
static void I2SDataTxRxActivate(void)+ I% Q  L9 Z6 A* A
{+ L, ]- S! B6 Z
/* Start the clocks */1 B6 [9 Z# c5 |" }+ S! i
McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);
* E( U. P7 z3 x1 i4 f. V5 }McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL);
/* Enable EDMA for the transfer */9 g. D$ [8 j$ ~/ J7 h8 C' y
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,
- ^. R! u  q( c9 O. m) I3 tEDMA3_TRIG_MODE_EVENT);
0 Q2 v8 e7 o. Y+ J6 ?1 e# p8 oEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS,
: X0 l' M# I; z% {7 K1 B' b5 cEDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT);
/* Activate the serializers *// \/ k. A; \8 U) N! c
McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);/ V1 ^. j8 J% P" D8 B
McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS);
/* make sure that the XDATA bit is cleared to zero */
7 U: \8 ~/ F( {& n; K3 Uwhile(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY);
/* Activate the state machines */
; O# R, E4 C, W3 BMcASPRxEnable(SOC_MCASP_0_CTRL_REGS);. {* m& J2 {' u7 n, i3 O4 F
McASPTxEnable(SOC_MCASP_0_CTRL_REGS);
  F4 X+ g" z- D" z}

+ v  H" u. A& @; i/ i
请问:问题出在哪了,时钟按照这样配是否有错。
另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0.

3 [7 V, L& c; C+ ]& X$ \




欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) Powered by Discuz! X3.4