|
|
C6747和C6748感觉差不多,我想实现McASP发送中断方式控制音频信号,在轮询的例程基础上改的,轮询程序可以实现,但是中断一直实现不了,也找不到错误,求大神帮忙!下边是主要程序:
6 ^% r. ?2 f8 Gmain文件:: H% ~8 X; Q3 N0 r2 i1 ?
interrupt void interrupt4(void)
3 @+ j' k7 W" o$ g/ h2 _9 C5 c{. L# k o1 X k& y' A! {
Uint32 sample;
4 I5 u# ~. r: E
& T) Z1 `7 V& J; ~5 T sample = input_sample(); // read L + R samples from ADC
* \% \- r2 f% B# q! |) C9 U2 f output_sample(sample); // write L + R samples to DAC
& @& C" b% k% W4 ~. V7 N( x1 ^- v return;( g2 K2 ]+ R! [% L4 p; U7 \" Q
}1 J" C+ |% F1 ?2 _
1 Z" e N6 ~* @2 Z% Oint main( void )
9 F6 [3 L# j3 o, J, h{- {# H# [* R4 C0 T9 A2 P
: m7 c6 ]% r7 ~; a2 e9 J /* Initialize BSL */
! E+ d" ]1 i# l( v EVMC6747_init( );
# k" t p6 L7 ?/ a# r/ |1 [; V /* Call evmc6747_intr function */& m" i0 F- q6 X: q/ v
aic3106_init( );
% h# \8 |2 H& h/ e9 K while(1);
0 X ~1 c1 R5 x+ ?6 o. _}5 A9 d" O$ S4 M$ t: ?
* e* K& l* k _( V& c, O7 w: D
7 g# N2 `% a. h" N; |. V$ }6 U! b
aic3106_init文件的一部分,McASP配置部分,采用内部时钟,I2S方式,同步传输。音频芯片的配置应该没问题1 f* p6 h- _" i3 ~$ I& w/ v5 f. i
/* Initialize MCASP1 */' E( T8 S S1 B% t
mcasp = &MCASP_MODULE_1;% V) ^' E2 e8 g# b
mcasp->regs->GBLCTL = 0; // Reset
* s3 {- B2 L5 C9 i: | mcasp->regs->RGBLCTL = 0; // Reset RX, D$ f. f/ ^+ Z
mcasp->regs->XGBLCTL = 0; // Reset TX
8 u! f. }) j$ w7 e( @ mcasp->regs->PWRDEMU = 1; // Free-running
) V' @6 |3 A4 V4 P* E% a3 | // configure McASP0 receive registers
, N5 s; w g x( Y8 O: O1 b( c mcasp->regs->RMASK = 0xFFFFFFFF; // No padding used9 ]' ^1 s9 _1 d
mcasp->regs->RFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus
: o; ^0 r. `: |$ V$ R4 V! o. f mcasp->regs->AFSRCTL = 0x00000112; // 2TDM, 1bit Falling, External FS, word P, a$ g+ l9 ~; R4 w
mcasp->regs->ACLKRCTL = 0x000000AF; // Rising INTERNAL CLK,(from tx side) p4 E( d! H6 w7 M& \+ \" Z
mcasp->regs->AHCLKRCTL = 0x00000000; // INT CLK (from tx side); H, h4 _3 |; F( V# Q0 k
mcasp->regs->RTDM = 0x00000003; // Slots 0,1
2 D! \( d7 [: V. M6 t# A mcasp->regs->RINTCTL = 0x00000000; // Not used
( q6 \. O1 R# k& ?& T mcasp->regs->RCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-2565 |9 f, T! r4 {& z9 W- T' `' e2 m
% S, j; j& C, T# h2 w
mcasp->regs->XMASK = 0xFFFFFFFF; // No padding used- V$ l1 a, e7 i5 v, k+ x2 ~5 v
mcasp->regs->XFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus# [/ f: ^! m |7 W: f6 f: k
mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word
$ V4 H2 B% n; w1 g+ } mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-16$ O' r4 h" {6 _
mcasp->regs->AHCLKXCTL = 0x00000000; // EXT CLK5 q e5 |& L9 l. W+ ?3 t+ Q
mcasp->regs->XTDM = 0x00000003; // Slots 0,1
. s8 K% R5 }( O T' ?# n6 G9 B mcasp->regs->XINTCTL = 0x00000020; // interrupt on transmit
5 M2 [, u i/ b4 Y. k$ j) `. s mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256
- i( i0 x, @+ W) ^" Z" I& U5 n! H; b
3 z' T0 r+ {6 G' } mcasp->regs->SRCTL5 = 0x000D; // MCASP1.AXR1[5] --> DIN' w% _7 f1 }! x2 G
mcasp->regs->SRCTL0 = 0x000E; // MCASP1.AXR1[0] <-- DOUT; n! w, y; B1 t/ S
mcasp->regs->PFUNC = 0; // All MCASPs
3 @- f# I2 a" o mcasp->regs->PDIR = 0x14000020; // All inputs except AXR0[5], ACLKX1, AFSX1; ~2 N9 G2 |; d4 |& m3 C/ ?
! j3 ]+ l: V" i l9 b4 O2 U V
mcasp->regs->DITCTL = 0x00000000; // Not used& ?4 _; C! I% k( |2 M( Z! j" ^
mcasp->regs->DLBCTL = 0x00000000; // Not used
% w! H* B" N# t* ^ mcasp->regs->AMUTE = 0x00000000; // Not used7 p1 I/ T% }6 `# O) a% W
# T! Y( o# e0 G8 r4 `
/* Starting sections of the McASP*/
; g9 b. }! F( M# d/ O F mcasp->regs->XGBLCTL |= GBLCTL_XHCLKRST_ON; - Q7 [8 p! O4 S( L
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XHCLKRST_ON ) != GBLCTL_XHCLKRST_ON ); 4 U2 J% H. S& _+ {: `# F1 @
mcasp->regs->RGBLCTL |= GBLCTL_RHCLKRST_ON;
7 v+ O, \% d; x while ( ( mcasp->regs->RGBLCTL & GBLCTL_RHCLKRST_ON ) != GBLCTL_RHCLKRST_ON );& h8 R' G3 I4 n
! R" @+ ~) z& G* U0 R3 k9 j3 c mcasp->regs->XGBLCTL |= GBLCTL_XCLKRST_ON;
9 Z$ e6 `/ @6 B! m9 ~ while ( ( mcasp->regs->XGBLCTL & GBLCTL_XCLKRST_ON ) != GBLCTL_XCLKRST_ON );0 \# Y$ x. \. [. U# N8 W
mcasp->regs->RGBLCTL |= GBLCTL_RCLKRST_ON; ' } Q$ ]; y4 `3 Q5 y: D
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RCLKRST_ON ) != GBLCTL_RCLKRST_ON );6 f P- ^* v. ]* j6 G" T. m
2 K/ Q8 k# q. }" C7 u+ r( S mcasp->regs->XSTAT = 0x0000ffff; 8 }- C) y1 H9 T$ K# R; H2 [" u. {
mcasp->regs->RSTAT = 0x0000ffff;
8 t" d! u% j6 x- \1 J) ]( Z5 G& Z
9 }' E: z* o6 |8 s4 @ mcasp->regs->XGBLCTL |= GBLCTL_XSRCLR_ON;
- I+ I# W% x- i& M while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSRCLR_ON ) != GBLCTL_XSRCLR_ON );
, v$ p& d$ P- x; H mcasp->regs->RGBLCTL |= GBLCTL_RSRCLR_ON;
- D" g! @: \, _4 z: Y6 l, `0 { while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSRCLR_ON ) != GBLCTL_RSRCLR_ON );
2 Z) w I% M: x5 T) S- H: t6 V
$ p: v+ K8 @! M# Y /* Write a 0, so that no underrun occurs after releasing the state machine */( T6 G) L: p$ [. \ b$ ~
mcasp->regs->XBUF5 = 0; A7 g* x2 M: s: |$ {& I# a6 P
mcasp->regs->RBUF0 = 0;9 t! l* L8 i& v; c# a) C7 v0 \! \" E
0 ?0 l3 I' I( ]+ u mcasp->regs->XGBLCTL |= GBLCTL_XSMRST_ON; - K7 u" W4 }& E+ h/ ?3 S( m
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSMRST_ON ) != GBLCTL_XSMRST_ON );
! `! s2 t5 @% J; u mcasp->regs->RGBLCTL |= GBLCTL_RSMRST_ON; 5 ^: M5 w: d" V( u7 X/ d2 U1 F" j
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSMRST_ON ) != GBLCTL_RSMRST_ON );
* A2 z) G* b7 `5 N/ k" k
( j9 z: x' |: \, r) R' N mcasp->regs->XGBLCTL |= GBLCTL_XFRST_ON; 3 ]& j8 O* c2 F/ U) d
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XFRST_ON ) != GBLCTL_XFRST_ON );% X, C) f/ Y+ t2 x7 R/ Z
mcasp->regs->RGBLCTL |= GBLCTL_RFRST_ON; 2 }7 d9 B( {1 Q# w; A7 I! i7 n
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RFRST_ON ) != GBLCTL_RFRST_ON );6 H( c; a) p: K( O0 ?. U; z
; Q( y$ N* x/ v% |' k$ I
CSR = 0x0000;
+ O! F. n5 z6 ^) ]! D v9 R INTC_INTMUX1 = 0x3d;
: g0 [4 K2 l" T; W# G- G1 a! r' S ISTP = (unsigned int)vectors;1 ~) y& V& g2 O( R* q
ICR = 0xFFF0; - k) V& @ w# h* b
IER |= 0x12;
3 p# j9 E' R: H$ f CSR |= 0x01;
# _! M* W$ Z& G' X* c a6 I' Z8 Y
+ B) V" f1 z C, G T8 ? D, U( w- R3 N* H; C: T! _& O! {
# g8 \! X% A6 y% A5 f还有就是两个输入输出函数:
' c/ B {7 _; \2 { cvoid output_sample(Int32 out_data): E6 U" H w* }
{' n9 @9 g2 G' w
AIC31_data.uint = out_data;
% |3 m3 o' C9 ^" ]8 o, ?: _ MCASP1_XBUF5_32BIT = AIC31_data.uint;
% l3 C! @" C( i8 D+ V, q}
& z+ N$ G# L/ O( f/ @
) l6 D, g4 n( j+ |" o- Y2 z9 k# NInt32 input_sample(void)1 ^/ R- P4 H+ {
{ 9 I+ K* B- ? C; G9 t$ ~
AIC31_data.uint = MCASP1_RBUF0_32BIT;; [. v6 D" k4 n2 h6 i. X
return (AIC31_data.uint);
& u/ w/ N& w( F$ ~# V+ T# ]5 T' F0 I}' c. A* u1 }8 f* J, K* Q) }* Y
0 @( z0 w7 d, `3 t3 Y |
|