|
|
C6747和C6748感觉差不多,我想实现McASP发送中断方式控制音频信号,在轮询的例程基础上改的,轮询程序可以实现,但是中断一直实现不了,也找不到错误,求大神帮忙!下边是主要程序:
1 {3 v, I2 W0 |! [% A8 K4 k1 ^: Nmain文件:1 v k) ^8 _; e0 J. V; z
interrupt void interrupt4(void)
& }2 k+ U, x8 q7 }{
, S" |0 H q5 H( h9 ~5 t Uint32 sample;" O4 Z& k# a& L8 ]5 Z
, X) B7 d5 t; u; |8 H- {
sample = input_sample(); // read L + R samples from ADC4 I% U& _. w0 I8 j4 ~
output_sample(sample); // write L + R samples to DAC
Y- {; l& T* ]5 _ return;
6 \$ M& ]/ [4 H! \1 {7 _$ J) V7 a}
) {9 y3 Q; [2 K9 U' ~. Z6 b$ @
7 |: j$ m) |5 [& d: aint main( void )( e* N2 m | h& Z) f
{
: F1 a t1 h! z k
4 e; _# M; b T" J; }1 k: B5 A7 D /* Initialize BSL */
/ q; L4 S# \( c EVMC6747_init( );
2 o7 @( h' S3 H, B) A /* Call evmc6747_intr function */
& C7 i1 g) j- s. }( j1 d# r aic3106_init( );
2 r4 |' o! A' y; n2 f2 M while(1);4 d; \7 X( G+ Q) m5 o2 L, Z3 u' r
}
$ c% y; u7 R% K, C) C& {* e+ x2 Q5 {" A3 ~5 ]
; V9 v& R- n$ w
aic3106_init文件的一部分,McASP配置部分,采用内部时钟,I2S方式,同步传输。音频芯片的配置应该没问题
- l3 X- X( o/ Z" D0 {' R k% L/* Initialize MCASP1 */% m; C; ~& M: _' _, J( p
mcasp = &MCASP_MODULE_1;# }. C5 F: X$ r7 F/ Q: D( v
mcasp->regs->GBLCTL = 0; // Reset
6 W- W0 H1 {. q5 C0 R% V mcasp->regs->RGBLCTL = 0; // Reset RX
h* X- y) Y P' w2 ]4 l! ^ mcasp->regs->XGBLCTL = 0; // Reset TX
& b9 ]9 V9 k' o* k' s mcasp->regs->PWRDEMU = 1; // Free-running
+ j5 b. V) J# N; M2 y // configure McASP0 receive registers
8 R9 x c: ?; @# G: n9 x0 @! X mcasp->regs->RMASK = 0xFFFFFFFF; // No padding used \& z' e/ n, _
mcasp->regs->RFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus
! k; x) i" V5 A# x3 s1 G. w mcasp->regs->AFSRCTL = 0x00000112; // 2TDM, 1bit Falling, External FS, word5 _+ J! ?( |! t# I0 p: t
mcasp->regs->ACLKRCTL = 0x000000AF; // Rising INTERNAL CLK,(from tx side)
7 h4 x" g8 r# ?$ u7 w; p+ V9 c mcasp->regs->AHCLKRCTL = 0x00000000; // INT CLK (from tx side)
& y+ E7 {& Y7 `; H0 H4 q/ `$ K mcasp->regs->RTDM = 0x00000003; // Slots 0,1
" l Z+ D7 p. H7 n! |- a mcasp->regs->RINTCTL = 0x00000000; // Not used% ~* p- I* {3 V1 X5 S3 I" k
mcasp->regs->RCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256. y- Y0 ?8 [7 I3 H: F
& V, {5 x; n# D" W0 d mcasp->regs->XMASK = 0xFFFFFFFF; // No padding used
* E7 [0 D1 ^, t0 j- g5 C" T- } mcasp->regs->XFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus( v! D/ F8 ?+ T+ j$ j, Q; k! x( g/ N
mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word
" F3 W; l9 v1 ?3 k2 `5 ^3 R' C. o1 N mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-16
* A% ~) Q" y' G, r8 E3 [ mcasp->regs->AHCLKXCTL = 0x00000000; // EXT CLK5 U2 d' H, p D9 _( W
mcasp->regs->XTDM = 0x00000003; // Slots 0,1& d4 C, p$ h Z7 U- n ~) ?, h1 o
mcasp->regs->XINTCTL = 0x00000020; // interrupt on transmit
1 G* d; M# A) V, \ mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256
; }" \0 n( d7 Z5 A
2 \( s0 D- M6 y mcasp->regs->SRCTL5 = 0x000D; // MCASP1.AXR1[5] --> DIN
+ w+ E: H& r3 K% `6 u) @6 z" O( D mcasp->regs->SRCTL0 = 0x000E; // MCASP1.AXR1[0] <-- DOUT7 g1 U" i% R7 U* a
mcasp->regs->PFUNC = 0; // All MCASPs
' S* b0 e, x+ s2 `1 z G mcasp->regs->PDIR = 0x14000020; // All inputs except AXR0[5], ACLKX1, AFSX1) V( Z6 o7 E8 s# v4 v2 W' @
4 Q% k. j+ K# z4 R* |' @+ I+ R
mcasp->regs->DITCTL = 0x00000000; // Not used
4 E8 Z2 r7 B$ S& L' ^% v- y6 Z mcasp->regs->DLBCTL = 0x00000000; // Not used
7 s: A3 x# E( `, H9 j mcasp->regs->AMUTE = 0x00000000; // Not used# N9 }# T( z* l
0 T- ^/ ^* U& R2 x
/* Starting sections of the McASP*/
; D6 z6 d: }% M9 V. i( t mcasp->regs->XGBLCTL |= GBLCTL_XHCLKRST_ON; 4 t, ^8 Z/ X- y* ?0 y
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XHCLKRST_ON ) != GBLCTL_XHCLKRST_ON );
0 b w1 B' |4 @/ a mcasp->regs->RGBLCTL |= GBLCTL_RHCLKRST_ON; / h9 D L. o# K
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RHCLKRST_ON ) != GBLCTL_RHCLKRST_ON );+ `9 b O7 y+ _" z! x/ i
2 S2 ]/ Q+ K6 U; a( I: y, b mcasp->regs->XGBLCTL |= GBLCTL_XCLKRST_ON; & E5 q# u c5 H
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XCLKRST_ON ) != GBLCTL_XCLKRST_ON );4 J, j- L! C. o% l) N: p* Z/ R* W
mcasp->regs->RGBLCTL |= GBLCTL_RCLKRST_ON; 8 \" s1 S7 W/ c7 M4 t, ?0 l' g+ }
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RCLKRST_ON ) != GBLCTL_RCLKRST_ON );
- [# i9 T5 @: m2 b( h" s4 z0 Z' M3 Q1 r7 p( e
mcasp->regs->XSTAT = 0x0000ffff; # R4 W9 u/ }# L4 b
mcasp->regs->RSTAT = 0x0000ffff;
$ B, C* e" w7 S
" c2 G' Y5 t/ _1 q J C6 i mcasp->regs->XGBLCTL |= GBLCTL_XSRCLR_ON;
' @/ h. q( q) K while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSRCLR_ON ) != GBLCTL_XSRCLR_ON );- w3 ^, |$ {9 [0 ~2 B
mcasp->regs->RGBLCTL |= GBLCTL_RSRCLR_ON; ~' X0 M! X; M" x
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSRCLR_ON ) != GBLCTL_RSRCLR_ON );
/ C( Q0 S9 u( u. @. t# ^# n: o1 O$ l# N( Z7 W9 P
/* Write a 0, so that no underrun occurs after releasing the state machine */
W" h5 J9 U7 p# K% M- x mcasp->regs->XBUF5 = 0;
' R, X% j5 x) `. [% a8 b: c8 _& A mcasp->regs->RBUF0 = 0;) l) d, O% I6 I; m7 b, o0 G
* C' O7 @" z X8 D* u$ T
mcasp->regs->XGBLCTL |= GBLCTL_XSMRST_ON; * P4 Y/ Z7 M2 a& ]3 @
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSMRST_ON ) != GBLCTL_XSMRST_ON );* L7 s) f7 Q* V4 G G3 v0 U
mcasp->regs->RGBLCTL |= GBLCTL_RSMRST_ON;
3 y) E. A% L& X" E9 k3 L& Y while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSMRST_ON ) != GBLCTL_RSMRST_ON );$ Z; Q4 O6 d" d: V8 V0 ]
& b y# h9 X" ] mcasp->regs->XGBLCTL |= GBLCTL_XFRST_ON; % {) V+ S! S0 u- a2 v
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XFRST_ON ) != GBLCTL_XFRST_ON );
. ?5 F+ s; i7 Y+ x4 }8 j% N& s% x mcasp->regs->RGBLCTL |= GBLCTL_RFRST_ON; 0 V2 M& b% ?8 [& K6 w# o5 ^' t4 _: v
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RFRST_ON ) != GBLCTL_RFRST_ON );! U+ W9 T8 P$ H8 Y ^7 [; Q
' E6 F* b( }% T9 A% c. b
CSR = 0x0000;; L1 @) G6 R! L4 L
INTC_INTMUX1 = 0x3d;# l' u: {* S2 v9 {8 o" Y
ISTP = (unsigned int)vectors;1 P0 e# t2 c* f3 o
ICR = 0xFFF0; ) e1 M- S8 ?" b
IER |= 0x12; , h2 }: Q6 x* W3 C# z" N
CSR |= 0x01;
) a( m7 o. _! k, a5 t5 h
! O2 X9 y! C! P2 D8 W4 U5 G' J! J( Q. E% i8 T
% K* }0 l' I' @
还有就是两个输入输出函数:9 I; D# _4 |" I+ y" B1 m6 Z
void output_sample(Int32 out_data)
4 R5 G9 d/ n) L# {) U{2 w8 @- E2 @" n1 N: V
AIC31_data.uint = out_data;
: P' K) R( C5 Q+ B0 P1 L MCASP1_XBUF5_32BIT = AIC31_data.uint;
0 `4 j6 ?5 a* D; s& w8 j% N}: b& E( z! j3 M% C& {* Q
" }, j; x7 H2 a9 d1 F. K* u
Int32 input_sample(void)' A) D1 c2 T" E5 B: b* ^* X
{
2 t# _/ Q4 z2 j; K3 f. s AIC31_data.uint = MCASP1_RBUF0_32BIT;3 ~" p% }, ^( |1 }: r5 P
return (AIC31_data.uint);
' p4 Y H7 _6 o" K3 c- Q}' _8 X0 N+ U" S% A2 D! F
4 `5 ^' [7 E: C- a- @ |
|