嵌入式开发者社区
标题: MCASP自环配置。 [打印本页]
作者: wapdasta 时间: 2018-11-7 13:28
标题: MCASP自环配置。
我项目上用OMAPL138的板子MCASP的引脚都是链接的FPGA,所以在FPGA这端设置的MCASP自环。把axr0接收到的通过axr1发回去。
部分代码如下
input mcasp_afsx,
. r! t6 V5 M/ s# @" v( O Iinput mcasp_ahclkx,
% {4 Y$ \* x7 u0 Rinput mcasp_aclkx,3 `0 X R" }9 `5 d) P
input axr0,
! g$ E& y' c; e1 s& P
: }: c( n2 i- V, t: Aoutput mcasp_afsr,
" L4 P8 K1 U: Z. ` A$ doutput mcasp_ahclkr,
+ m' B+ L" S7 }% R! T; E$ F- f- poutput mcasp_aclkr,: [ z4 @$ k! @3 Q% @/ M I" v
output axr1,
! A8 q: R; e; c4 p
assign mcasp_afsr = mcasp_afsx;
$ E0 a1 ]$ N. l. yassign mcasp_aclkr = mcasp_aclkx;
: P8 l, Y* q' Hassign mcasp_ahclkr = mcasp_ahclkx;# m- \6 f* z" G$ y
assign axr1 = axr0;
4 y7 R7 u% Q; m( l
8 g( ?' a$ |9 P/ K+ } O% f在OMAPL138这端,通过axr0接口发固定的数,axr1接收。
在配置MACASP的时候,发送全部取内部时钟,接收全部取外部时钟。
一直循环发送,但是接收不到。在FPGA端也没有看到时钟和信号的波形。
部分代码如下,关于edma3的部分未做变化。
+ R* u; p0 d+ w/ R4 h- q! c+ B* _& h
static void McASPI2SConfigure(void)
+ d) {! U+ O: k( H{
X6 f8 g6 {; i, ?& i lMcASPRxReset(SOC_MCASP_0_CTRL_REGS);, U0 k0 J4 ]! O( w6 P/ Q9 P' X
McASPTxReset(SOC_MCASP_0_CTRL_REGS);
/* Enable the FIFOs for DMA transfer */
7 K5 N$ T( o9 I! D; j* h1 bMcASPReadFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);* x. ]% r2 F' N! S* X
McASPWriteFifoEnable(SOC_MCASP_0_FIFO_REGS, 1, 1);
/* Set I2S format in the transmitter/receiver format units */
7 z5 L% z/ i2 @5 T& SMcASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,% [$ W7 r6 ^- v& L( c
MCASP_RX_MODE_DMA);
. p, k0 k( s% n7 UMcASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE,+ x; d8 Y5 V& {* g4 d- w
MCASP_TX_MODE_DMA);
/* Configure the frame sync. I2S shall work in TDM format with 2 slots */
; ^% n' D+ p7 k' P. vMcASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, o' ?; E" i ]* y1 ]% s
MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE);+ b- c& ?: l7 }. i& r3 s8 y" ^
McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD, ) t: F$ N% h# p5 m& _
MCASP_TX_FS_INT_BEGIN_ON_RIS_EDGE);
/* configure the clock for receiver */1 o6 k5 g0 Y5 l4 H& \
McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0);+ C$ I" M" c3 M, }
McASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE); & o2 [% F- K' ^9 y
McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32,) O0 T0 @. g4 h/ m$ v; t
0x00, 0xFF);
/* configure the clock for transmitter */
; ~* E) o& \; {' d( K- T4 h' j tMcASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL, 11, 1);
$ v$ m4 }5 Q7 s( {5 yMcASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE);
- r& P, e4 A# N( wMcASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32,
* j) \3 i8 y9 L+ c0x00, 0xFF);5 Y A; G; T5 f) V$ d
8 @8 C+ @+ E3 }( x, ~1 y
/* Enable synchronization of RX and TX sections */ v" ^7 \5 n5 R Z
McASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS);
/* Enable the transmitter/receiver slots. I2S uses 2 slots */
# M$ I4 K1 J! E) _( {" wMcASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
5 j4 Y D, ]% T3 j1 i* Q, sMcASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS);
/*# b( ^; B4 ]# K
** Set the serializers, Currently only one serializer is set as" u+ b& ~" j4 q& a5 l+ V9 Y) e
** transmitter and one serializer as receiver.
% P$ q8 R5 z ^: ~$ E*/, f' h/ F( m! z* g3 S/ `. M3 {
McASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX);
( J& i; j' q: y8 t0 G: N6 bMcASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX);
/*
0 o. F+ n1 ~8 ~" V( y** Configure the McASP pins 2 G4 A' Q! y' L# k* c' j1 J2 W
** Input - Frame Sync, Clock and Serializer Rx9 a/ h A/ z" p7 s7 [4 X5 h
** Output - Serializer Tx is connected to the input of the codec # n! B& i P V1 Z
*/
4 S) U3 W; ^$ B3 A: `& X# XMcASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF);
) l: h4 D( V! T9 y9 L2 KMcASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS,MCASP_PIN_AXR(MCASP_XSER_TX));
: x) P# |" x9 E! V+ HMcASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX( p0 a1 c) _( o; Q4 k
| MCASP_PIN_ACLKX$ o2 F- f h9 u8 O1 ~ E
| MCASP_PIN_AHCLKX
' M" F- B+ G1 A7 ~' r; O| MCASP_PIN_AXR(MCASP_XSER_RX));
/* Enable error interrupts for McASP */: t/ o# F' ^$ Q7 z
McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR / r# B, U! d) A' `+ {2 R. F. z+ n6 S, a
| MCASP_TX_CLKFAIL
, ^/ q% t. P3 B3 G! h! j| MCASP_TX_SYNCERROR. C [4 W0 D0 P/ s6 y
| MCASP_TX_UNDERRUN);
McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DMAERROR
2 n! N- v0 W( @* {( S: Q| MCASP_RX_CLKFAIL
; Q% ^$ h' [# L3 V| MCASP_RX_SYNCERROR * t/ ]# w) U. B( Z# \
| MCASP_RX_OVERRUN);
' w' v5 a- u4 v. s0 Z& W: L4 ^}
static void I2SDataTxRxActivate(void) h+ ]* l* o6 V! A( H# l
{. S6 X) K! V, E5 [4 O5 Q
/* Start the clocks */3 y5 [% ^6 u0 \
McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);- @- `* M8 I$ L' ~- N5 R& ]
McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_INTERNAL);
/* Enable EDMA for the transfer */" C1 h' a' O$ q' l! k
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCASP0_RX,
: a( L& k/ ?0 w7 \) F* pEDMA3_TRIG_MODE_EVENT);
* _8 ~7 p" B/ @8 m9 SEDMA3EnableTransfer(SOC_EDMA30CC_0_REGS,
8 Q) M S0 k( _; tEDMA3_CHA_MCASP0_TX, EDMA3_TRIG_MODE_EVENT);
/* Activate the serializers */4 H# |3 x: s4 O, e, U
McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS); f( s2 y1 N: @
McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS);
/* make sure that the XDATA bit is cleared to zero */1 f4 j ~' W; A. `4 ?
while(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY);
/* Activate the state machines *// @8 H: ]% |- d- j. |
McASPRxEnable(SOC_MCASP_0_CTRL_REGS);
. V1 _! @! f! WMcASPTxEnable(SOC_MCASP_0_CTRL_REGS);
3 y. U7 x3 b3 l' S, Y7 Z5 w}
/ U/ X. g, f ?+ {" d) \& u! D
请问:问题出在哪了,时钟按照这样配是否有错。
另外我看XDATA一直是0,接收的rxbuf0,1,2里有一般全是FFFF一半全是0.
$ {- ?3 z6 F) n3 Z
| 欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) |
Powered by Discuz! X3.4 |