嵌入式开发者社区
标题: MCASP自环配置。 [打印本页]
作者: wapdasta 时间: 2018-11-7 13:28
标题: MCASP自环配置。
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。
部分代码如下
input mcasp_afsx,* A* ^+ |9 Z4 d N* v0 \% }
input mcasp_ahclkx,7 ?1 @5 I2 r) i% }4 E4 B# l* M( y
input mcasp_aclkx,1 M, w, h; q' w( U' ]: E4 R& e
input axr0,
) x) W* S, r6 K$ p* _; [5 u4 }% ^. I0 a2 K; p
output mcasp_afsr,: a3 C) i% _1 q' [
output mcasp_ahclkr,1 K( B0 S' Q9 Q1 D. o
output mcasp_aclkr,
3 \2 A/ }/ |: b$ i8 f+ r4 soutput axr1,$ d/ z. M& _: y8 Q" A( U, X+ g
assign mcasp_afsr = mcasp_afsx;
/ S" h5 Y% N! ], a- ]! t: qassign mcasp_aclkr = mcasp_aclkx;* Y" k9 C8 B" f9 S) ?3 y! F
assign mcasp_ahclkr = mcasp_ahclkx;3 Y `# c5 s% Z0 m; i2 r# w
assign axr1 = axr0;
H" B! ~) T$ h" {+ e- r
% I% q8 F! U2 r' M/ ~在OMAPL138这端,通过axr0接口发固定的数,axr1接收。
在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。
一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。
部分代码如下,关于edma3的部分未做变化。
+ y9 ]2 N1 G$ C. y. hstatic void McASPI2SConfigure(void)7 Q5 ?# I6 \( X+ H; {) I3 o$ P
{
' R4 v+ j" @7 g; fMcASPRxReset(SOC_MCASP_0_CTRL_REGS);6 P! U4 N& Q8 a% F
McASPTxReset(SOC_MCASP_0_CTRL_REGS);
/* Enable the FIFOs for DMA transfer */
- r0 E6 ~4 M$ Q9 iMcASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);8 J' Q/ s! ^6 [# i$ h, s
McASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
/* Set I2S format in the transmitter/receiver format units */$ @8 ?+ X( R' W0 N
McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,
/ ^/ r7 Y' O JMCASP_RX_MODE_DMA);
# ` a1 B. @1 q7 F# \& G* ZMcASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,7 k+ r9 G' r1 u& H# t( [' d4 j" `
MCASP_TX_MODE_DMA);
/* Configure the frame sync. I2S shall work in TDM format with 2 slots */
: s0 c9 O% k( ?3 P4 B; V3 a- |6 v2 hMcASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, * l/ r2 h% E m$ @, f- ~
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);
8 x4 c5 ~/ S5 E$ A+ x qMcASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD, : T3 k$ X3 X5 i! B# ?
MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE);
/* configure the clock for receiver */
* g+ k: A- K; A' DMcASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);
) h3 F$ @. S: d' j' s. RMcASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE);
X5 [3 j8 Q d* L1 k s6 hMcASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,' T& o* c" f3 j! j7 p
0x00, 0xFF);
/* configure the clock for transmitter *// |# w& n' u2 e5 o+ R
McASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);
, x2 \, c+ ]2 ]& t! n. l) U- N2 zMcASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
7 A" K# B, u VMcASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32," e5 L" F+ Z$ V b% v! K1 N
0x00, 0xFF);7 k# `; R, K9 y: [
% G" U- h. B; E( k7 E/* Enable synchronization of RX and TX sections */
; Q' F3 ?3 X5 n" p6 ^McASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS);
/* Enable the transmitter/receiver slots. I2S uses 2 slots */- p0 E, ?3 _$ ?2 i; n) {
McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
5 d) h" J" ]8 y& E/ W/ S J2 ~1 iMcASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
/** D) B& G [ Z% P3 I) Q! f# h
** Set the serializers, Currently only one serializer is set as
7 Y2 u$ Y/ h' Q$ S% k% m) H9 z** transmitter and one serializer as receiver.5 S# f8 d, |. m2 A
*/
! V! `7 K+ C" u* x+ aMcASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
8 d! s7 d) a1 B U5 n# xMcASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX);
/*! O4 }0 |, P: Q( K
** Configure the McASP pins
' A( ?& V2 [1 K8 p9 z** Input - Frame Sync, Clock and Serializer Rx
3 V$ N u8 h8 v** Output - Serializer Tx is connected to the input of the codec
3 o! v3 W+ Q5 t*/
7 }- w5 h- L/ T! c/ xMcASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);
0 y0 a) Y/ U0 lMcASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));
$ q. x7 {: P3 J$ J* Z! m/ }' H- oMcASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX
$ ]1 ~8 r/ F4 o( L% P+ K9 s% y| MCASP_PIN_ACLKX4 ?7 t8 Y& W$ [7 l; C5 Y2 B
| MCASP_PIN_AHCLKX# X& J$ A+ n2 ~2 L0 E
| MCASP_PIN_AXR(MCASP_XSER_RX));
/* Enable error interrupts for McASP */ C2 s, k9 t" ?- }; F7 c
McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR ; P+ W' D+ _3 x
| MCASP_TX_CLKFAIL
3 @) C) {3 m K5 q, ^; O| MCASP_TX_SYNCERROR) V2 e0 O& A' N7 V) k8 o
| MCASP_TX_UNDERRUN);
McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR " P7 V" T* c" s. {, D# n$ ~$ }+ Y
| MCASP_RX_CLKFAIL" Z" A3 w( u f4 w2 M: [. V- `
| MCASP_RX_SYNCERROR 0 a5 C% b- t$ N% U. c c4 I7 V+ A
| MCASP_RX_OVERRUN);
, l K; ?! l/ U}
static void I2SDataTxRxActivate(void), f7 p2 }+ ^2 D, A0 _3 y
{* }9 Q n7 ?) t' n2 u
/* Start the clocks */
8 L/ e- R# z3 b5 CMcASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);
* x/ C% Z$ q/ I) g1 `McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL);
/* Enable EDMA for the transfer */
- T! t1 }4 \4 s2 iEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,- k* h* L8 ?1 J6 P5 V5 a
EDMA3_TRIG_MODE_EVENT);7 C' f( w/ q) v9 p( h( W Z! {
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, " @5 w: f0 i5 e( K& n
EDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT);
/* Activate the serializers */2 B7 A F' A! y6 B- Q9 t
McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);$ t1 a3 \( \! p( w! y! R
McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS);
/* make sure that the XDATA bit is cleared to zero */
- L7 B& |% k* wwhile(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY);
/* Activate the state machines */
+ P% u5 a6 q p" H. EMcASPRxEnable(SOC_MCASP_0_CTRL_REGS);
" ?5 W. X5 P4 p6 p7 b! xMcASPTxEnable(SOC_MCASP_0_CTRL_REGS);7 Y* j% }# r2 J3 G, a0 Q
}
. u/ q1 n0 i' x: W7 G' v请问:问题出在哪了,时钟按照这样配是否有错。
另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0.
3 R+ w# I; u; m
| 欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) |
Powered by Discuz! X3.4 |