|
|
C6747和C6748感觉差不多,我想实现McASP发送中断方式控制音频信号,在轮询的例程基础上改的,轮询程序可以实现,但是中断一直实现不了,也找不到错误,求大神帮忙!下边是主要程序:5 _9 o) v% R4 a9 C
main文件:
# o- f6 g1 e* J7 A7 N- E, ]interrupt void interrupt4(void) ' i5 M& e% F2 H3 G# G0 G& R
{5 y" i" h6 w# |- }6 c
Uint32 sample;0 V8 G9 r, i1 B$ F$ K7 d
& q( E2 Y$ N+ v- V- | sample = input_sample(); // read L + R samples from ADC* I8 s* J9 q3 v) `1 a! m3 D
output_sample(sample); // write L + R samples to DAC
/ D; A# c4 j; s5 Z0 S7 V return;# \5 W, ~+ j7 |: q; M8 e
}; ~, a* z |* Q8 Y
. w1 @1 R7 j0 gint main( void )$ i o* q. u- l/ c
{3 s) f& u, I0 H* L
5 K; [" O8 _8 |0 J: F3 W2 G0 k /* Initialize BSL */
: R0 Z9 e% R% D3 t EVMC6747_init( );2 u5 i% a+ B9 C9 c5 F; w
/* Call evmc6747_intr function */" \& e* y# E9 e2 d# v+ h2 T
aic3106_init( );
9 l, ?9 m( r: q! ~ while(1);
6 S. A ~! F% M/ X# l( l7 y8 k}* ]. M* _( f5 `, @) g, l
! {( {3 k2 C( P# a" \& ~' C1 j. x$ D- {7 O& E9 n
aic3106_init文件的一部分,McASP配置部分,采用内部时钟,I2S方式,同步传输。音频芯片的配置应该没问题3 p5 L q m* \/ Y7 n5 t+ K3 t
/* Initialize MCASP1 */5 o/ _+ t7 [7 y! _) F
mcasp = &MCASP_MODULE_1;
/ u. {2 Y8 X7 r1 } mcasp->regs->GBLCTL = 0; // Reset5 e4 N. f- O6 @( G
mcasp->regs->RGBLCTL = 0; // Reset RX' b W& X% A [5 H% b
mcasp->regs->XGBLCTL = 0; // Reset TX8 l/ l% ^! L4 ]
mcasp->regs->PWRDEMU = 1; // Free-running
B- V8 a" w$ K& [% a4 u4 V // configure McASP0 receive registers
5 I0 x& G4 D( H/ w/ p1 t1 n7 f$ h mcasp->regs->RMASK = 0xFFFFFFFF; // No padding used% J: t0 O% m! h J! C
mcasp->regs->RFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus
6 V; m W4 q* K* F2 [" p) ^ mcasp->regs->AFSRCTL = 0x00000112; // 2TDM, 1bit Falling, External FS, word8 o* m+ H1 c* s* Z( r: D! I
mcasp->regs->ACLKRCTL = 0x000000AF; // Rising INTERNAL CLK,(from tx side)7 r; ^1 [) Q& D( x ^; O5 k" W2 Z
mcasp->regs->AHCLKRCTL = 0x00000000; // INT CLK (from tx side)) K/ u& L: X; ^
mcasp->regs->RTDM = 0x00000003; // Slots 0,1
9 H g# T: e; K ~, Z mcasp->regs->RINTCTL = 0x00000000; // Not used
& S# E1 ]/ m. }" P) E mcasp->regs->RCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256# [* |" I5 D3 I+ x' b" J
3 r' i: P7 E% O' S) a5 Z; O
mcasp->regs->XMASK = 0xFFFFFFFF; // No padding used5 r8 X0 z, _3 @4 T+ `
mcasp->regs->XFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus; c9 l* c- l1 w) R) W& a
mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word6 S# k! C% k q! i
mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-16
2 ]* t! L) c7 s mcasp->regs->AHCLKXCTL = 0x00000000; // EXT CLK( F7 Q% P" {6 z& c& \ ?- P6 y
mcasp->regs->XTDM = 0x00000003; // Slots 0,1
0 P) L9 {& h& p3 w* q0 m mcasp->regs->XINTCTL = 0x00000020; // interrupt on transmit
; y0 K& k" n. H5 `: e g" m mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256
# X$ [5 U% V7 P: S1 ~% g2 o' a; ^: C, [
mcasp->regs->SRCTL5 = 0x000D; // MCASP1.AXR1[5] --> DIN4 L! t0 F8 ^9 D
mcasp->regs->SRCTL0 = 0x000E; // MCASP1.AXR1[0] <-- DOUT
: N- s8 p5 t/ X7 h( g% |! f _( ^( W2 J8 ` mcasp->regs->PFUNC = 0; // All MCASPs4 \- H! U( F" J9 Z
mcasp->regs->PDIR = 0x14000020; // All inputs except AXR0[5], ACLKX1, AFSX1
- }% d, ]- B5 k. C q& Y( x8 i" q; K2 X* L# e- s" M# l5 a, h! A; i5 p8 H, T
mcasp->regs->DITCTL = 0x00000000; // Not used8 c- `$ B) [' G. s
mcasp->regs->DLBCTL = 0x00000000; // Not used) b) Q# ?) o- U
mcasp->regs->AMUTE = 0x00000000; // Not used$ T& l0 E* C3 \
: W" j0 @4 {6 k: E3 J/* Starting sections of the McASP*/
4 r$ [4 ~( d# F" w% t: H0 I mcasp->regs->XGBLCTL |= GBLCTL_XHCLKRST_ON; ) }# P6 a+ _- y" u# n
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XHCLKRST_ON ) != GBLCTL_XHCLKRST_ON );
% U* M. z$ y* w, y2 h: A c6 L mcasp->regs->RGBLCTL |= GBLCTL_RHCLKRST_ON; 9 o6 [, R; J& G3 X2 F4 I7 A
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RHCLKRST_ON ) != GBLCTL_RHCLKRST_ON );
! _0 c7 v3 [( S- K0 [- ]
4 b! g- o" ^2 p) M, i mcasp->regs->XGBLCTL |= GBLCTL_XCLKRST_ON; 6 D# [4 Z; E0 s$ i2 |1 G9 n
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XCLKRST_ON ) != GBLCTL_XCLKRST_ON );
4 c/ x5 O* g* E) n4 t mcasp->regs->RGBLCTL |= GBLCTL_RCLKRST_ON;
8 Q8 ]) m* H" j! X while ( ( mcasp->regs->RGBLCTL & GBLCTL_RCLKRST_ON ) != GBLCTL_RCLKRST_ON );; {* E6 ]7 }! `+ P* K. F, B& d! ?
- |: ]* X. L5 u, p mcasp->regs->XSTAT = 0x0000ffff; 9 W& D5 c) r% f: U
mcasp->regs->RSTAT = 0x0000ffff;
5 E* F, e: {: F) n( e1 S
/ l, b8 n& }& G9 v mcasp->regs->XGBLCTL |= GBLCTL_XSRCLR_ON;
* E. d* J% l- e while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSRCLR_ON ) != GBLCTL_XSRCLR_ON );, u5 x" }6 v$ P
mcasp->regs->RGBLCTL |= GBLCTL_RSRCLR_ON;
$ v2 R, ?4 P/ z while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSRCLR_ON ) != GBLCTL_RSRCLR_ON );2 z! H. W. a, h8 T
, ` Y7 w G! F9 C7 u/ [7 x: X
/* Write a 0, so that no underrun occurs after releasing the state machine */
( A2 x6 v; o) I- \0 O mcasp->regs->XBUF5 = 0;+ J% q3 k7 m9 O: i: H G5 C
mcasp->regs->RBUF0 = 0;
7 d i. q6 j8 p
7 N' E& S9 ]! X6 J- P& K3 n; c M mcasp->regs->XGBLCTL |= GBLCTL_XSMRST_ON;
$ E% D3 f) p5 s while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSMRST_ON ) != GBLCTL_XSMRST_ON );
/ ^* s/ f. [1 S% M mcasp->regs->RGBLCTL |= GBLCTL_RSMRST_ON;
% d( ?: a% o% s/ B$ v0 @ while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSMRST_ON ) != GBLCTL_RSMRST_ON );9 T0 r& E8 F, Z
" Q- k1 _" ?7 u @; N, ~
mcasp->regs->XGBLCTL |= GBLCTL_XFRST_ON;
4 Y9 o- {( V) ?) R& g9 `6 C: w' P while ( ( mcasp->regs->XGBLCTL & GBLCTL_XFRST_ON ) != GBLCTL_XFRST_ON );/ w6 x! n' ~8 j" _
mcasp->regs->RGBLCTL |= GBLCTL_RFRST_ON; 6 a. e' H2 G% t. L0 J5 {
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RFRST_ON ) != GBLCTL_RFRST_ON );+ j2 s0 K/ b q& I! G4 G }
, D1 c* @$ X/ h5 g; M7 k9 {6 q CSR = 0x0000;0 l" Y8 R2 \; { q& g- |$ ?
INTC_INTMUX1 = 0x3d;; w1 i& |1 h# z1 B1 `: c
ISTP = (unsigned int)vectors;! C; V6 f' o4 M8 G# K
ICR = 0xFFF0; 5 k$ w# l& P: T0 ^: {# r0 n: e
IER |= 0x12; $ x' x4 l3 c+ ?$ {) l6 j* M
CSR |= 0x01; 6 N! E8 V# M( ^0 r. G! e1 K
0 J; |/ R2 F1 i2 i: }* Q7 b' l. a8 P6 R: ^: H
: G2 M9 {( g- ?6 n/ H还有就是两个输入输出函数:7 k R% D) m8 X
void output_sample(Int32 out_data)8 ]3 r# k# [2 |) B: E! \2 t3 }
{
$ n4 O% M; t! E* R9 \' p9 h$ E5 o. V; M AIC31_data.uint = out_data; ! s+ f- T$ P0 m4 q# ]& D5 M3 u
MCASP1_XBUF5_32BIT = AIC31_data.uint;
, J5 C- @) h5 w5 s0 y5 `& d5 r}6 I: T7 c! U6 r; C) u
7 T8 I& r0 C6 }! q0 b* PInt32 input_sample(void)" P+ J( k/ t7 _4 h
{ ' c; t( v) L5 u" t$ u3 e- Z
AIC31_data.uint = MCASP1_RBUF0_32BIT;; d; e3 S* K9 q# G
return (AIC31_data.uint);
- x& K; [1 R) j) q" N6 N}
# s' C* \1 s! o9 i/ r4 i- o! F% ~* C& j* ^" @8 _3 L! [
|
|