|
|
C6747和C6748感觉差不多,我想实现McASP发送中断方式控制音频信号,在轮询的例程基础上改的,轮询程序可以实现,但是中断一直实现不了,也找不到错误,求大神帮忙!下边是主要程序:1 [6 t( A8 J& f' ^# A2 B' W- h3 z4 T
main文件:
, k" H9 z2 N/ F4 G, Einterrupt void interrupt4(void)
2 d( V$ c+ J3 T; l& ^8 I, n{
: i( Y2 j7 u+ M$ S1 t" ~. k Uint32 sample;
7 K' e% k9 p4 c3 ?: p4 \) ]5 F! l8 k5 r5 M2 r
sample = input_sample(); // read L + R samples from ADC6 M1 E- B1 f; B( n- U2 G+ r
output_sample(sample); // write L + R samples to DAC Y0 ^9 m5 A5 ~ D6 q. t; M! E
return;; \0 P6 S; w8 c5 Z# H
}. L- O; Y9 {% H% \/ N% l- u
4 X" t. d3 T2 z3 w; {- W
int main( void )
9 H" s8 ~9 z3 f0 H5 ]+ ^) L{, g. D- ?) h; N+ v: _3 ?$ L+ ?9 J5 b
x0 x/ `% ^+ `; Y: \. m( ?/ Q /* Initialize BSL */
. _1 f+ h: i8 q2 m: w EVMC6747_init( );
* }% c; ~( V9 }8 T /* Call evmc6747_intr function */
% v* h0 G; I7 S4 v2 \ aic3106_init( );1 g+ C! f7 ~* i
while(1);: `) d8 {) u" p; S: V x+ A
}$ p4 o; h" O( S) h
, d1 Q. e$ }& d" x1 s$ @0 u
7 a& @6 b. w2 s* m% w
aic3106_init文件的一部分,McASP配置部分,采用内部时钟,I2S方式,同步传输。音频芯片的配置应该没问题0 @: Y! a- E7 A
/* Initialize MCASP1 */
! ]+ [6 Y# x0 V# Z R" X$ y mcasp = &MCASP_MODULE_1;2 e0 R# p+ a# P" }& f# R
mcasp->regs->GBLCTL = 0; // Reset2 f( r$ \; Z3 ~3 u+ ^: ~
mcasp->regs->RGBLCTL = 0; // Reset RX5 f1 X8 K3 o2 t* F+ T# m) D3 j
mcasp->regs->XGBLCTL = 0; // Reset TX
- [7 q% U0 Q6 R- r; s/ r mcasp->regs->PWRDEMU = 1; // Free-running9 j: E. e% v$ @ v2 t3 m4 a ~
// configure McASP0 receive registers' ]0 O. ?! j8 j
mcasp->regs->RMASK = 0xFFFFFFFF; // No padding used
! z3 _! G: h0 e5 j mcasp->regs->RFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus5 ^3 U; \" R$ k
mcasp->regs->AFSRCTL = 0x00000112; // 2TDM, 1bit Falling, External FS, word
" L! }2 k; T; @7 x: q& D1 `0 t2 g mcasp->regs->ACLKRCTL = 0x000000AF; // Rising INTERNAL CLK,(from tx side)
8 x9 z" ~ E( c; _ mcasp->regs->AHCLKRCTL = 0x00000000; // INT CLK (from tx side)
& j) P; H; Q2 l8 W& E1 X$ F" U9 |- O8 v mcasp->regs->RTDM = 0x00000003; // Slots 0,11 ?/ T! s8 m+ _! ~) N
mcasp->regs->RINTCTL = 0x00000000; // Not used6 a/ {% b* x! g' J0 w$ u
mcasp->regs->RCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256
: L6 z" l1 I/ u' B: ?) U8 b' s& O! {" R# ~- e; V
mcasp->regs->XMASK = 0xFFFFFFFF; // No padding used! W4 x; y* s, l+ h: n( T( q- P
mcasp->regs->XFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus/ H+ U: |: k) ^" {4 A! c0 o' `
mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word) M! p- M F. \+ ~9 p0 O
mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-162 Z( ]7 }$ s1 w8 Z2 u2 w& Q5 N5 ~
mcasp->regs->AHCLKXCTL = 0x00000000; // EXT CLK# @% O/ G' n" J) U+ c
mcasp->regs->XTDM = 0x00000003; // Slots 0,16 V9 ^% Q) x" w, I* n4 P& p) C) O
mcasp->regs->XINTCTL = 0x00000020; // interrupt on transmit
' P" O: k# ?) }; ~ mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256. M( b7 I# {+ v z
' ?9 r Q4 M1 y; M! _) |& v
mcasp->regs->SRCTL5 = 0x000D; // MCASP1.AXR1[5] --> DIN- H1 i# y8 |3 Y% G9 m1 c
mcasp->regs->SRCTL0 = 0x000E; // MCASP1.AXR1[0] <-- DOUT0 A, l4 i- c, h8 d
mcasp->regs->PFUNC = 0; // All MCASPs' z2 U) J, C2 [8 I
mcasp->regs->PDIR = 0x14000020; // All inputs except AXR0[5], ACLKX1, AFSX1
& |5 `; z L# a* [# H1 P& v! U: P* F
mcasp->regs->DITCTL = 0x00000000; // Not used L) Q4 W1 t4 e/ o( d6 |3 h
mcasp->regs->DLBCTL = 0x00000000; // Not used
9 P' Q* a2 P2 A' T$ B mcasp->regs->AMUTE = 0x00000000; // Not used
) v( O; N- `% k7 w6 B* H7 @' h0 ?3 V
/* Starting sections of the McASP*/4 t7 @! Q" H9 a/ b9 q& g
mcasp->regs->XGBLCTL |= GBLCTL_XHCLKRST_ON;
, ~+ _ E5 f: Z3 A( U# F5 u& M5 P while ( ( mcasp->regs->XGBLCTL & GBLCTL_XHCLKRST_ON ) != GBLCTL_XHCLKRST_ON ); " ^- U3 I/ N# C& m" Q4 {
mcasp->regs->RGBLCTL |= GBLCTL_RHCLKRST_ON;
, P3 v* ^$ `# n while ( ( mcasp->regs->RGBLCTL & GBLCTL_RHCLKRST_ON ) != GBLCTL_RHCLKRST_ON );
! Z6 C) l3 Z# Q" ], K* C5 a# v; I! q: G! e- x
mcasp->regs->XGBLCTL |= GBLCTL_XCLKRST_ON;
0 f. P8 }: e- X( A. Y/ L/ }: M while ( ( mcasp->regs->XGBLCTL & GBLCTL_XCLKRST_ON ) != GBLCTL_XCLKRST_ON );
5 l. U* c! t, O0 R% c2 H mcasp->regs->RGBLCTL |= GBLCTL_RCLKRST_ON;
3 h! `. t5 s, {% K) e( B while ( ( mcasp->regs->RGBLCTL & GBLCTL_RCLKRST_ON ) != GBLCTL_RCLKRST_ON );
3 x0 _, X, G; X( ~+ q1 X; J$ l- H( d% j3 {' _7 S
mcasp->regs->XSTAT = 0x0000ffff;
3 K" c. I0 t; [5 D M8 @: u. i mcasp->regs->RSTAT = 0x0000ffff;
% {4 g5 s/ n6 ~5 w! Q3 U3 k5 A% ^- F# L+ w9 N; t) k9 ~- j
mcasp->regs->XGBLCTL |= GBLCTL_XSRCLR_ON;) g6 @* ?# ^& a8 N# X
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSRCLR_ON ) != GBLCTL_XSRCLR_ON );. V9 ^9 b* F: Z% @
mcasp->regs->RGBLCTL |= GBLCTL_RSRCLR_ON; & x/ F+ W3 V3 N/ J/ R
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSRCLR_ON ) != GBLCTL_RSRCLR_ON );
0 h; o% x# ]! M% ~+ \, q& T! k
% m+ }" v- Q$ _4 B3 F O /* Write a 0, so that no underrun occurs after releasing the state machine */
, r9 S4 y4 M3 r2 y mcasp->regs->XBUF5 = 0;& w6 I. ~) p! C6 Y- V* j
mcasp->regs->RBUF0 = 0;
& u8 N v7 m2 f, H5 G
( X- a+ Q$ } Q6 {/ |+ s mcasp->regs->XGBLCTL |= GBLCTL_XSMRST_ON; + q5 _& I9 o4 e2 A% B* L: }
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSMRST_ON ) != GBLCTL_XSMRST_ON );
- k; ]. a8 D0 u: n/ g2 | mcasp->regs->RGBLCTL |= GBLCTL_RSMRST_ON; 1 O/ q ~1 |: H& s9 ?3 x+ d2 G
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSMRST_ON ) != GBLCTL_RSMRST_ON );
2 u( w4 r9 m) D# M8 X
5 O+ \& m5 M. Y4 j0 P mcasp->regs->XGBLCTL |= GBLCTL_XFRST_ON; 3 {; O/ W$ s& |7 r3 L% G
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XFRST_ON ) != GBLCTL_XFRST_ON );; E. G5 d' L" y
mcasp->regs->RGBLCTL |= GBLCTL_RFRST_ON;
; v0 A* T2 t Q6 ? while ( ( mcasp->regs->RGBLCTL & GBLCTL_RFRST_ON ) != GBLCTL_RFRST_ON );& {9 e+ D" e9 g" @1 u9 _$ x
$ Z7 m6 r: W: L* F; r9 I3 R' v
CSR = 0x0000;; E: H$ i7 v6 ]& e
INTC_INTMUX1 = 0x3d;9 [' M& W4 a/ ?. W# G
ISTP = (unsigned int)vectors;' W, s/ @& O# S* M
ICR = 0xFFF0;
4 H5 c( Z0 p+ @& _ IER |= 0x12; # \. S9 F! D9 y$ v
CSR |= 0x01; 0 l3 }/ v3 i0 \3 ^1 x" i
7 G2 N5 m$ z1 m/ M* K& V
5 P- M* R5 R: b: P3 U3 j6 K; y& D+ r/ k
还有就是两个输入输出函数:/ _7 Z D' c0 n: x$ S
void output_sample(Int32 out_data)6 b, Q8 K+ g0 `) J
{. j: c h" o2 t3 {0 X' t& v
AIC31_data.uint = out_data;
P3 W5 b$ O7 E7 Z1 ~* c' ] MCASP1_XBUF5_32BIT = AIC31_data.uint;
" ~0 R+ X" p/ x0 `& d} ~+ q/ }0 N+ P% R$ K7 |& S
0 V% { }# @8 \& L- TInt32 input_sample(void)
3 u# p9 t* _6 |: ]) u0 W% x5 a{
$ }+ I+ |4 X) f v }7 h. y AIC31_data.uint = MCASP1_RBUF0_32BIT;3 N+ t- A/ v, C1 K
return (AIC31_data.uint);
7 }6 U; @3 P1 s1 j6 K}
1 `- d1 a# `2 Z1 B% O a2 e0 Y4 @4 Z: b) k# Y# o% U a- t( ^) z' U
|
|