|
|
C6747和C6748感觉差不多,我想实现McASP发送中断方式控制音频信号,在轮询的例程基础上改的,轮询程序可以实现,但是中断一直实现不了,也找不到错误,求大神帮忙!下边是主要程序:+ v7 Q, \/ M# l$ j
main文件:4 y4 y5 l, g a* q- {0 z
interrupt void interrupt4(void) ( B' F- A# C% {" D
{" T# n- C/ |0 J; U. L& n
Uint32 sample;
, s7 d) s% N: k2 u" W# J" j- g5 ^7 V: j9 X- a
sample = input_sample(); // read L + R samples from ADC
- H! R [: q( q# c1 |# ?* w output_sample(sample); // write L + R samples to DAC ! O" ]/ A* ~. }
return;
* i3 @& D4 R- X1 L+ {/ b}9 z7 |' h" R y! K
9 e$ ]1 S4 P+ `" D' Lint main( void )7 W; U$ c' a- K3 J; H
{0 U8 v* Q: A9 t2 O
4 ~7 `/ `4 H9 {7 |5 w+ u /* Initialize BSL */
0 N/ k% n9 t# p! M1 |. S& e EVMC6747_init( );. K* @1 t! f8 f) ]. D
/* Call evmc6747_intr function */
% Z8 P( y: o. p5 [ aic3106_init( );% p+ x* v/ r5 @
while(1);
# ]$ ^" u! t" f9 I: j}
, y8 K9 `6 F$ D. ~9 R2 F& P K1 _7 v- V( P) Y
1 @. y Y& s8 o# Z# l5 taic3106_init文件的一部分,McASP配置部分,采用内部时钟,I2S方式,同步传输。音频芯片的配置应该没问题
, {- K4 R+ W8 p/* Initialize MCASP1 */
+ Q" a. J) ?# G' g; b mcasp = &MCASP_MODULE_1;
! Z2 @: w0 r' j mcasp->regs->GBLCTL = 0; // Reset- }! U9 Y" o r ]. L
mcasp->regs->RGBLCTL = 0; // Reset RX
6 _ D' R- i; N! [* k5 I6 P" Q8 @% ~ mcasp->regs->XGBLCTL = 0; // Reset TX7 N: r( F$ C q& k0 K1 P" Z* R: D
mcasp->regs->PWRDEMU = 1; // Free-running+ S0 U( b7 u4 X' }
// configure McASP0 receive registers
' P+ J$ t {8 {8 a mcasp->regs->RMASK = 0xFFFFFFFF; // No padding used
% ] I; D- |& ]1 ^9 e+ U mcasp->regs->RFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus
7 X; ~4 b* [: s2 `" j; ^3 I& k2 p mcasp->regs->AFSRCTL = 0x00000112; // 2TDM, 1bit Falling, External FS, word
0 C% g) D5 ^4 ~% b' q* B mcasp->regs->ACLKRCTL = 0x000000AF; // Rising INTERNAL CLK,(from tx side)5 L) n8 O8 t1 y, o) K: U
mcasp->regs->AHCLKRCTL = 0x00000000; // INT CLK (from tx side)8 U$ e( _5 g+ N5 c
mcasp->regs->RTDM = 0x00000003; // Slots 0,1
4 D0 f( y' h4 `6 Q! Z7 S' B mcasp->regs->RINTCTL = 0x00000000; // Not used
: m0 B# J& o0 B; h" {9 d) ]. i' g mcasp->regs->RCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256( v" Y8 G) J3 T Y% y
' _& @0 E8 v' R, ^5 ~6 B/ O mcasp->regs->XMASK = 0xFFFFFFFF; // No padding used: X) v+ s7 D& O: v0 q8 S; _6 K
mcasp->regs->XFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus8 V0 t! X1 C2 ~! M) c# a% H
mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word/ {# {7 O: u! H- n+ m! c& O1 F' u
mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-16
0 \# J" X+ Y. n! D+ E mcasp->regs->AHCLKXCTL = 0x00000000; // EXT CLK y6 u. N5 }5 ~* }7 z7 ~+ H
mcasp->regs->XTDM = 0x00000003; // Slots 0,1
0 X2 m# U i9 ~ mcasp->regs->XINTCTL = 0x00000020; // interrupt on transmit6 i% b/ ]3 L5 u" \4 L
mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-2569 |; C2 x1 N! K
# |( x3 r# o: d* z! H% W2 f mcasp->regs->SRCTL5 = 0x000D; // MCASP1.AXR1[5] --> DIN% a0 G3 N4 u1 M. f0 A# P' n
mcasp->regs->SRCTL0 = 0x000E; // MCASP1.AXR1[0] <-- DOUT
3 ?) \/ |' ^. ]0 i3 Q' y; I+ s' T7 a mcasp->regs->PFUNC = 0; // All MCASPs
5 i0 s6 i) ~) ]2 k y# }, I6 `9 d mcasp->regs->PDIR = 0x14000020; // All inputs except AXR0[5], ACLKX1, AFSX1
5 B+ H8 p4 T* p& x
) S; W* q: H* w0 Z2 C0 z mcasp->regs->DITCTL = 0x00000000; // Not used
4 Q/ q6 J8 o, W; l2 X# D U mcasp->regs->DLBCTL = 0x00000000; // Not used3 D S# t* u* F; A
mcasp->regs->AMUTE = 0x00000000; // Not used- v6 R+ A2 N1 ^$ L7 ^8 M; S
1 z1 U; ]- r- x9 d/* Starting sections of the McASP*/, k' o3 M0 Q7 U; E, r$ s' U$ P+ b
mcasp->regs->XGBLCTL |= GBLCTL_XHCLKRST_ON; 2 M8 S2 a$ _: [# M$ j
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XHCLKRST_ON ) != GBLCTL_XHCLKRST_ON );
0 A; E$ J6 Y! k" i9 q2 r2 o mcasp->regs->RGBLCTL |= GBLCTL_RHCLKRST_ON; ' E2 p' H; `% h1 x
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RHCLKRST_ON ) != GBLCTL_RHCLKRST_ON );& R% P6 Y/ T: a' d
' j8 t1 X$ z7 Y+ R6 X3 S
mcasp->regs->XGBLCTL |= GBLCTL_XCLKRST_ON;
" {* J4 I" q# W: Y4 ]$ ~ while ( ( mcasp->regs->XGBLCTL & GBLCTL_XCLKRST_ON ) != GBLCTL_XCLKRST_ON );4 G# k' g* y, `/ L; |* S$ z
mcasp->regs->RGBLCTL |= GBLCTL_RCLKRST_ON;
3 T$ D8 l5 p7 i8 S* J while ( ( mcasp->regs->RGBLCTL & GBLCTL_RCLKRST_ON ) != GBLCTL_RCLKRST_ON );" m) G7 D+ Y* m' \( r
# G; E `& y: Z mcasp->regs->XSTAT = 0x0000ffff; # Q3 S# f: W$ D! @4 X
mcasp->regs->RSTAT = 0x0000ffff; ; v5 T! I! o* Z0 B/ M: u p
" L( O, {8 {3 T! Q) W mcasp->regs->XGBLCTL |= GBLCTL_XSRCLR_ON;
2 L5 F! @1 w3 U- A& x while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSRCLR_ON ) != GBLCTL_XSRCLR_ON );
( P" y: M6 Q/ Y6 z5 l mcasp->regs->RGBLCTL |= GBLCTL_RSRCLR_ON; + N9 Q* J# M i o8 t, B/ X
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSRCLR_ON ) != GBLCTL_RSRCLR_ON );
9 i+ D L/ ]5 s! z3 C
( p$ E z' f" z /* Write a 0, so that no underrun occurs after releasing the state machine */
$ U4 v7 l2 z. S7 s mcasp->regs->XBUF5 = 0;4 w$ B8 n0 S) Y9 ^4 H( e3 g3 }, W
mcasp->regs->RBUF0 = 0;" o/ o* B' X: z. Z8 G! p
. j9 R" O4 u2 v9 ^$ }1 a3 V, p/ G mcasp->regs->XGBLCTL |= GBLCTL_XSMRST_ON; ' w$ b4 [" u' `( e* X7 a+ }* ?
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSMRST_ON ) != GBLCTL_XSMRST_ON );
/ @; h h3 \6 o9 e# N& N mcasp->regs->RGBLCTL |= GBLCTL_RSMRST_ON; 8 Y& I9 r. v: Y2 o+ |4 P3 {
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSMRST_ON ) != GBLCTL_RSMRST_ON );+ Y: W) O" Y3 V# P3 n- G; q
: u/ z0 l4 j5 P% Z9 _ mcasp->regs->XGBLCTL |= GBLCTL_XFRST_ON;
- @7 s$ C# j5 H) s/ X while ( ( mcasp->regs->XGBLCTL & GBLCTL_XFRST_ON ) != GBLCTL_XFRST_ON );
8 W( W' O0 ?& m1 [' k- B9 X mcasp->regs->RGBLCTL |= GBLCTL_RFRST_ON;
$ i. n' g- s! Y( Z& T, [ while ( ( mcasp->regs->RGBLCTL & GBLCTL_RFRST_ON ) != GBLCTL_RFRST_ON );
) N: ^% J+ u1 g* R* P4 J" X/ h T5 y/ w2 S# q' u7 r
CSR = 0x0000;& q% T7 V# g3 X+ E! `$ B* h5 K
INTC_INTMUX1 = 0x3d;" a: g# s1 R3 T+ w1 W7 k
ISTP = (unsigned int)vectors;
; T& f" p: R8 R6 S ICR = 0xFFF0;
. U; [& ?2 w; a IER |= 0x12; # M4 w& v! ?" d5 _
CSR |= 0x01; 8 L$ ]- K, f# n1 [" u; o4 z
: ^$ S' L }5 B5 ` D) ?5 Z& j V; W" f3 Z' F6 p5 l7 E
. c) g! v. j1 Z! q% p
还有就是两个输入输出函数:' b% m+ \1 L2 d Q0 v ^' P
void output_sample(Int32 out_data)1 L, w0 K; S6 ~& d
{/ g9 Y& c1 i2 x2 D0 \
AIC31_data.uint = out_data; 2 G$ L9 {$ m! o! U) u1 O
MCASP1_XBUF5_32BIT = AIC31_data.uint;
+ C; t% `. h& R9 Q1 _5 l" ^}
2 O) h& S/ `& A D/ n" f4 c5 f6 x8 a1 Z9 c* s
Int32 input_sample(void)
& `% m; t, u( w+ C5 x8 V" _{ 1 L3 _) {6 ]/ [ B( m3 u
AIC31_data.uint = MCASP1_RBUF0_32BIT;( V3 ^* z v- S2 M1 V) X
return (AIC31_data.uint);
/ e( Z# r+ i9 ~} P! R( J1 j0 Q% ]/ h+ L
0 y9 t8 p4 B3 ~; O) ~8 U
|
|