|
|
C6747和C6748感觉差不多,我想实现McASP发送中断方式控制音频信号,在轮询的例程基础上改的,轮询程序可以实现,但是中断一直实现不了,也找不到错误,求大神帮忙!下边是主要程序:+ G! @* u( k _7 l/ K3 P* L) Z
main文件:
! y9 Y* D5 B; ~* Ainterrupt void interrupt4(void) : I9 v. Z+ M y. l
{
5 [9 o; M: Z2 w Uint32 sample;
" C5 z7 X; v0 B6 |$ B( P8 G. b8 I g* b: Q4 f
sample = input_sample(); // read L + R samples from ADC- P4 t7 J, L( _- G" E
output_sample(sample); // write L + R samples to DAC
- [ p# Y* l8 Q return;: ]. s! {; @9 Z
}
& d6 N: F: F. _$ C$ a" W
! X( m6 l( Z2 W% N( b: eint main( void )
- @9 g( i& h3 v; F+ G8 H' J{& c3 t# ^2 b' ^( l% I6 P4 Z4 M' [
' J: W, L/ `' w; G4 v /* Initialize BSL */
, b, q* B3 S6 R% a2 s EVMC6747_init( );
- L8 k' R0 q' }/ r3 o /* Call evmc6747_intr function */
9 H5 k. b. n4 x7 ~- \ aic3106_init( );
# {; I' K) E9 J! g while(1);
& @6 |8 \5 i1 Q, A3 R}
/ ~( L2 a, Q7 j f/ x7 W4 m6 L) h$ A
" e. b i1 E" n/ v! U
aic3106_init文件的一部分,McASP配置部分,采用内部时钟,I2S方式,同步传输。音频芯片的配置应该没问题1 I% s& y7 D' e" M1 q
/* Initialize MCASP1 */
1 l( I0 I! l7 L/ m, m. Q5 g mcasp = &MCASP_MODULE_1;
5 k/ B$ s* e8 c$ O" X mcasp->regs->GBLCTL = 0; // Reset
7 x1 B8 u1 G0 w6 M) S7 @# _ mcasp->regs->RGBLCTL = 0; // Reset RX& {) z8 R/ Q) T5 q6 u
mcasp->regs->XGBLCTL = 0; // Reset TX* I0 e. g# V; L
mcasp->regs->PWRDEMU = 1; // Free-running
0 A% r& `3 l, | // configure McASP0 receive registers. {% N; U9 Z$ h8 E# @3 |2 X5 |
mcasp->regs->RMASK = 0xFFFFFFFF; // No padding used0 F3 w# }+ S! y% g4 g
mcasp->regs->RFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus
% g5 O* B3 o- C8 U( m6 m, Q mcasp->regs->AFSRCTL = 0x00000112; // 2TDM, 1bit Falling, External FS, word) T9 ~- i; S7 w& _5 ]" `# y* O6 E
mcasp->regs->ACLKRCTL = 0x000000AF; // Rising INTERNAL CLK,(from tx side)' a' I% C S( l8 w# k
mcasp->regs->AHCLKRCTL = 0x00000000; // INT CLK (from tx side)( T$ R z2 m+ w/ Z: J1 |. C
mcasp->regs->RTDM = 0x00000003; // Slots 0,17 z" S7 v1 A# i
mcasp->regs->RINTCTL = 0x00000000; // Not used
' g$ j' g# H- `6 r: D d mcasp->regs->RCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256' O/ H2 M }3 Q
3 }* V. R6 a. s: P) p& \
mcasp->regs->XMASK = 0xFFFFFFFF; // No padding used9 C9 ]" D* T$ E8 j/ A' C
mcasp->regs->XFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus' c# ~$ `2 J5 {; G" F( N
mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word% Z: o3 ]& e; n" }% I2 l7 q
mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-163 b, O2 d' R+ O3 I8 b \
mcasp->regs->AHCLKXCTL = 0x00000000; // EXT CLK
$ S2 j# A$ r: ^5 I mcasp->regs->XTDM = 0x00000003; // Slots 0,1/ {" `: m6 W& `' E2 p3 J% V
mcasp->regs->XINTCTL = 0x00000020; // interrupt on transmit7 @$ e7 E2 U O" k) t( l
mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256& V6 R( ?, s, D: w5 s5 P* M: e
/ f) G4 [6 E8 M2 w2 S( j. C mcasp->regs->SRCTL5 = 0x000D; // MCASP1.AXR1[5] --> DIN
( p5 b# X5 m) G1 |0 g mcasp->regs->SRCTL0 = 0x000E; // MCASP1.AXR1[0] <-- DOUT
5 A- R& E& H, A2 [. d9 }. X mcasp->regs->PFUNC = 0; // All MCASPs9 e4 _- Y) S2 J9 ~% F' {( C! g
mcasp->regs->PDIR = 0x14000020; // All inputs except AXR0[5], ACLKX1, AFSX1: g4 K- b+ F4 Y% \
7 k! t7 d/ X5 Y1 L1 `' L; z2 G mcasp->regs->DITCTL = 0x00000000; // Not used$ D( m8 p& Y! ~$ O- i0 v
mcasp->regs->DLBCTL = 0x00000000; // Not used
9 U' y5 E8 s. k0 h mcasp->regs->AMUTE = 0x00000000; // Not used6 p5 |+ i0 j: A, x& @
+ P& {' \( o) D) W; \- a8 t' `+ b/* Starting sections of the McASP*/
7 @+ o/ U% B. _' \, R% {0 K; C( d mcasp->regs->XGBLCTL |= GBLCTL_XHCLKRST_ON; ; f$ c5 M3 H5 J8 K) f9 r
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XHCLKRST_ON ) != GBLCTL_XHCLKRST_ON ); 4 r2 n( q' D# n7 v& k }
mcasp->regs->RGBLCTL |= GBLCTL_RHCLKRST_ON; % q* {! ^( T6 R2 N# p( \* b
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RHCLKRST_ON ) != GBLCTL_RHCLKRST_ON );% S% O6 b+ ?$ c5 V1 R
8 o* E4 F. a) K7 W7 m' t! f- T mcasp->regs->XGBLCTL |= GBLCTL_XCLKRST_ON;
9 q( R; X1 Z: Q& o while ( ( mcasp->regs->XGBLCTL & GBLCTL_XCLKRST_ON ) != GBLCTL_XCLKRST_ON );$ d1 \ P9 B7 H% i H9 [( m/ P7 I9 T
mcasp->regs->RGBLCTL |= GBLCTL_RCLKRST_ON; . I4 K7 S& V3 e9 g5 E. \0 {1 @
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RCLKRST_ON ) != GBLCTL_RCLKRST_ON );4 Q0 m5 O+ s; [' Z2 C
L' m' w! j" V; ?& s# N" |- w% i mcasp->regs->XSTAT = 0x0000ffff; 8 c! `, H+ q9 _, ^0 p+ E% ~( j H k
mcasp->regs->RSTAT = 0x0000ffff; X. e4 _; ?2 [6 o
1 M, ]2 ^ @: j3 l, W mcasp->regs->XGBLCTL |= GBLCTL_XSRCLR_ON;
8 h5 o0 {* Z' M8 }7 f# V9 [" X while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSRCLR_ON ) != GBLCTL_XSRCLR_ON );6 q- g9 w* w" W4 }+ k
mcasp->regs->RGBLCTL |= GBLCTL_RSRCLR_ON;
8 F( j; d( x) h/ S. f& J. p- s. P+ p4 O- h- j while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSRCLR_ON ) != GBLCTL_RSRCLR_ON );0 C. O& G% s# X7 f/ r( o. a
l; t* o6 g4 f& x5 g /* Write a 0, so that no underrun occurs after releasing the state machine */
2 E3 Z0 Y3 m l! \ mcasp->regs->XBUF5 = 0;
. D$ P! }& J: w7 u0 R: e mcasp->regs->RBUF0 = 0;
* A. X/ `! V: ~
$ R. ~1 q! `5 `2 J4 ], G3 | mcasp->regs->XGBLCTL |= GBLCTL_XSMRST_ON; 2 u6 ]- Z* [5 n" z1 P( W, \7 z
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSMRST_ON ) != GBLCTL_XSMRST_ON );; b7 e; S& b, q1 N- d0 R7 f
mcasp->regs->RGBLCTL |= GBLCTL_RSMRST_ON; 9 O6 c! u! G! j0 P1 l+ d4 O$ y
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSMRST_ON ) != GBLCTL_RSMRST_ON );6 a; [+ A9 X7 s! L
6 c+ v5 d9 ?6 }0 _: U mcasp->regs->XGBLCTL |= GBLCTL_XFRST_ON;
: w6 c; S9 k( ~8 ]* g2 A while ( ( mcasp->regs->XGBLCTL & GBLCTL_XFRST_ON ) != GBLCTL_XFRST_ON );8 r' f8 `. j* r; ?; T7 V
mcasp->regs->RGBLCTL |= GBLCTL_RFRST_ON; + I' }9 U- A/ D Z' W/ [
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RFRST_ON ) != GBLCTL_RFRST_ON );
: K) y/ Y3 u$ |2 ?$ {+ E3 Q% [% x8 ^- j4 U! s
CSR = 0x0000;
, J/ m. D# R& G x9 S- @- s/ ^ INTC_INTMUX1 = 0x3d;' y" i; ^% r8 g( \
ISTP = (unsigned int)vectors;% \! L; F9 h% ` X# q0 j
ICR = 0xFFF0; % B* b. m! U1 |- @
IER |= 0x12;
" x( s0 f- ?" h6 J0 u0 h3 [ CSR |= 0x01; 5 K: `+ ^7 ]- s( _7 N5 T. |; a
: {' l; j, s; d) ?2 H# \& G
+ K0 }: Q3 E6 V) l- E& n+ y0 w
: z1 F8 j' L, Q. r还有就是两个输入输出函数:
+ e; ]# ~8 O" Uvoid output_sample(Int32 out_data)' O" F d, t6 m2 `
{
1 c. ?9 j+ r* V- u. { AIC31_data.uint = out_data;
9 M' W _$ x( X1 d MCASP1_XBUF5_32BIT = AIC31_data.uint;
% I! V$ z# X' e9 Y0 T4 {}9 U0 z1 F- p; T" [! t
2 J, O b+ _& N
Int32 input_sample(void)
; ~( u, t- B: ~& Q- J* K: D7 ]{ . j, Q% S1 S B$ Q! i+ v7 f
AIC31_data.uint = MCASP1_RBUF0_32BIT;6 a1 K% f% N9 `7 M& `
return (AIC31_data.uint);
1 N) d- T5 H5 T$ `( [+ N! R* @}5 q* m" ^1 _# K G6 L% T$ j5 | s
" z& W% F& t/ ^) i
|
|