|
|
C6747和C6748感觉差不多,我想实现McASP发送中断方式控制音频信号,在轮询的例程基础上改的,轮询程序可以实现,但是中断一直实现不了,也找不到错误,求大神帮忙!下边是主要程序:8 O8 Y2 F, M- f9 P6 B' n4 G6 |
main文件:7 H+ s' R! [) g% l; m
interrupt void interrupt4(void)
/ T$ `2 B8 ]3 J. H0 F2 m{
. S( _8 A; q+ P: S Uint32 sample;
[4 ?/ D$ |9 Q# o# \, U' Q! n
7 T# J7 e6 J$ Z6 k, K sample = input_sample(); // read L + R samples from ADC
, _) k1 S# e Q `# \ output_sample(sample); // write L + R samples to DAC
2 K! D& Z: K, _/ q+ y9 x return;* f( Y# R+ h8 ]" x
}) n( O% \1 ^- @4 L4 k
! H O" n5 S: ?4 Dint main( void )' N$ j0 o8 R% s) s
{6 ?' s( a, v) }- f4 F
- Z" T! [9 G5 Q8 J6 U8 f$ m$ |% B
/* Initialize BSL */
G: w2 R+ ? v0 e& h EVMC6747_init( );
% w) j: X! x* J. Y( g2 n8 j /* Call evmc6747_intr function */+ _: R7 [+ Z, l* B& p/ ~
aic3106_init( );; ?/ c$ N& e4 i' e7 j3 Q7 h
while(1);
" F% J0 R( S! [+ ~3 ?}
/ {" ~6 k6 }4 H7 g% s8 R- A( B5 P. Y. ^
9 ^) x4 ?, F$ {; P( Z. r
aic3106_init文件的一部分,McASP配置部分,采用内部时钟,I2S方式,同步传输。音频芯片的配置应该没问题
* T7 E8 A/ I( ]4 e) `3 b/* Initialize MCASP1 */
, c+ i0 J* I, {" S+ g mcasp = &MCASP_MODULE_1;
0 \+ H8 A0 ?1 ^, Y3 a* G$ {$ u+ H+ { mcasp->regs->GBLCTL = 0; // Reset
! n- C9 i+ n* t mcasp->regs->RGBLCTL = 0; // Reset RX* }: E- L) X- A, ^
mcasp->regs->XGBLCTL = 0; // Reset TX/ Q8 r. j$ ^, n! z
mcasp->regs->PWRDEMU = 1; // Free-running
& l' h# T4 G8 ]0 w4 G. Y // configure McASP0 receive registers
F7 C8 t* Q( Q* I. C+ h* L mcasp->regs->RMASK = 0xFFFFFFFF; // No padding used
+ O, }- G3 r- S) x2 R mcasp->regs->RFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus8 d2 n) G% ^% F, j9 ]8 [' R" S
mcasp->regs->AFSRCTL = 0x00000112; // 2TDM, 1bit Falling, External FS, word3 ?+ }' ^; Y7 T# L0 x/ X; ^4 P$ f
mcasp->regs->ACLKRCTL = 0x000000AF; // Rising INTERNAL CLK,(from tx side)# k2 U, p k0 @/ v/ u
mcasp->regs->AHCLKRCTL = 0x00000000; // INT CLK (from tx side)
5 P% t5 S. |$ p mcasp->regs->RTDM = 0x00000003; // Slots 0,1
: Q3 x) K: m( r/ o# d mcasp->regs->RINTCTL = 0x00000000; // Not used3 h% b/ E4 q+ u! A D/ K4 J8 Z' \
mcasp->regs->RCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256: ~2 C5 A) S" q
f. _8 u; g* s
mcasp->regs->XMASK = 0xFFFFFFFF; // No padding used
( g, X h; ]4 K7 ~ mcasp->regs->XFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus0 Y" O- k. v- { ?7 B" R
mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word C# L2 K- M+ q$ A
mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-16
+ F6 C) y( D# v8 ~' u0 i+ E# l mcasp->regs->AHCLKXCTL = 0x00000000; // EXT CLK( z' E5 J4 v" E3 I' t% C5 s
mcasp->regs->XTDM = 0x00000003; // Slots 0,1
5 B/ g# e7 @! n+ @: ~ C) S mcasp->regs->XINTCTL = 0x00000020; // interrupt on transmit
1 P' K/ H! q: X7 N. _ mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-2560 z& p- B" a! \/ u3 g% W9 i( m
+ D! W7 l. [' F" }) x$ B mcasp->regs->SRCTL5 = 0x000D; // MCASP1.AXR1[5] --> DIN
! D0 h5 m% v, R6 N. B! s. l* F mcasp->regs->SRCTL0 = 0x000E; // MCASP1.AXR1[0] <-- DOUT
, b# p# b! S3 J. Q' v* k/ J$ R1 j mcasp->regs->PFUNC = 0; // All MCASPs3 \ t$ B& ^: z2 U7 a$ ^
mcasp->regs->PDIR = 0x14000020; // All inputs except AXR0[5], ACLKX1, AFSX1
' }/ u) Q ]; J
4 S- _: D) U* S6 C7 a, B t mcasp->regs->DITCTL = 0x00000000; // Not used! `: m& _& x: }" H& e( w4 n
mcasp->regs->DLBCTL = 0x00000000; // Not used
4 t% ~) Z5 ^; g& m) } mcasp->regs->AMUTE = 0x00000000; // Not used
1 d, i) Q/ c" j! t8 M8 ]* {0 H! [, o, d/ ^3 Q$ E
/* Starting sections of the McASP*/
8 n, D2 b: s* c8 V" B mcasp->regs->XGBLCTL |= GBLCTL_XHCLKRST_ON; 6 x0 o) x8 t) J$ v+ E0 Z/ m9 P
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XHCLKRST_ON ) != GBLCTL_XHCLKRST_ON );
2 A" E: S* i7 E9 l8 ^. ? mcasp->regs->RGBLCTL |= GBLCTL_RHCLKRST_ON; V9 g: l3 q' Z7 z9 P
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RHCLKRST_ON ) != GBLCTL_RHCLKRST_ON );
4 Q$ m/ `" k2 n, `( K
- D7 n: F, C5 x mcasp->regs->XGBLCTL |= GBLCTL_XCLKRST_ON;
8 \ A2 x4 d+ `5 h while ( ( mcasp->regs->XGBLCTL & GBLCTL_XCLKRST_ON ) != GBLCTL_XCLKRST_ON );' \7 Q7 o! Y% T/ W. x! m: w
mcasp->regs->RGBLCTL |= GBLCTL_RCLKRST_ON;
! t2 E; E( N0 B& ^4 e9 [ S while ( ( mcasp->regs->RGBLCTL & GBLCTL_RCLKRST_ON ) != GBLCTL_RCLKRST_ON );
2 X$ L6 t d, @' o! Q/ h/ @0 z# Z$ }1 s
mcasp->regs->XSTAT = 0x0000ffff;
. I; [4 m$ R; V% {+ r! c mcasp->regs->RSTAT = 0x0000ffff;
; p1 l$ p1 x; O, m* f ?1 C) D( m5 b# `
mcasp->regs->XGBLCTL |= GBLCTL_XSRCLR_ON;
5 ] p+ S8 h, L; l2 A" I2 M while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSRCLR_ON ) != GBLCTL_XSRCLR_ON );+ b3 Z" \9 j3 X/ h* b: K7 N' E
mcasp->regs->RGBLCTL |= GBLCTL_RSRCLR_ON;
; r u2 ?# H7 K while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSRCLR_ON ) != GBLCTL_RSRCLR_ON );0 w; A. M+ Q( N
# r% [0 r/ B; x$ U2 L9 [* w9 z6 j /* Write a 0, so that no underrun occurs after releasing the state machine */* M' n4 ~( c0 C3 V. }; [/ ]
mcasp->regs->XBUF5 = 0;! o3 i$ Q; E4 b4 o
mcasp->regs->RBUF0 = 0;% ^8 m" W; C Q
) {" S' N% r8 _& S5 e8 K8 s mcasp->regs->XGBLCTL |= GBLCTL_XSMRST_ON; ; t1 p' x$ j$ C" X" z9 u
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSMRST_ON ) != GBLCTL_XSMRST_ON );
: i( u4 B l) h* l; a mcasp->regs->RGBLCTL |= GBLCTL_RSMRST_ON;
7 i j2 I" n0 B8 J while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSMRST_ON ) != GBLCTL_RSMRST_ON );6 J9 K1 R7 x6 v/ ^
1 n D/ L5 E4 w$ M3 \ mcasp->regs->XGBLCTL |= GBLCTL_XFRST_ON; 4 L8 g) P$ i; F* d
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XFRST_ON ) != GBLCTL_XFRST_ON );
& x. T0 Y; t% Y5 | K mcasp->regs->RGBLCTL |= GBLCTL_RFRST_ON;
: M, R2 z! a0 C6 r% P \ while ( ( mcasp->regs->RGBLCTL & GBLCTL_RFRST_ON ) != GBLCTL_RFRST_ON );3 m1 i4 A, a7 d N+ ~7 e8 J
" _$ n' x5 r: ?, F9 P6 h1 P5 l CSR = 0x0000;
% d8 [* F/ x5 h* [; I& n7 v INTC_INTMUX1 = 0x3d;4 a( b" T9 y+ @1 Y
ISTP = (unsigned int)vectors;
/ K9 H5 ^+ G8 {7 ]% v6 K" K ICR = 0xFFF0;
: l: j) }) M2 ]1 i' e; X IER |= 0x12;
/ a: g$ Y' T$ l; U% ` CSR |= 0x01;
/ t2 L5 A2 b+ z2 a) z, e `7 ^0 G/ D8 _, t# r3 |# Y
) N# H ~8 q/ g' b2 p( w) t: T1 r
( ~$ {$ u8 a2 M( g3 u! `* n/ l还有就是两个输入输出函数:+ V1 v0 r9 {, l8 ]
void output_sample(Int32 out_data)
. K7 H/ D1 w- }{
7 g; e% w, s0 f! ?: w7 Q1 m AIC31_data.uint = out_data;
- P' h5 J+ _$ X$ D& `! R MCASP1_XBUF5_32BIT = AIC31_data.uint;- f$ i0 l3 C- a* }9 a" m4 i% O
}
* @" w3 h( r# }1 @+ s; J2 P. b# u/ C. O$ Y7 v# h6 U
Int32 input_sample(void)! E' _# Y9 V- p4 R0 @ D1 \8 P& q
{
8 C3 R* P" |9 { L1 Y! m AIC31_data.uint = MCASP1_RBUF0_32BIT;4 G7 I3 S C0 T" p' c/ w
return (AIC31_data.uint);( A, @) w5 Z; n
}3 s3 d# ^' c9 g6 `& Y6 r1 D
) Y% f' j2 |$ g' b. t' u* |
|
|