|
|
C6747和C6748感觉差不多,我想实现McASP发送中断方式控制音频信号,在轮询的例程基础上改的,轮询程序可以实现,但是中断一直实现不了,也找不到错误,求大神帮忙!下边是主要程序:
( _. S5 d D3 X, K/ t) k4 d& nmain文件:
! ~- Z; D6 x2 q# I$ U3 w0 cinterrupt void interrupt4(void)
7 f6 ^6 W8 o8 E& K{0 V4 b+ u& {1 D" {
Uint32 sample;
, t0 B! a4 o0 } J# l; j: M4 J( n# t6 ~8 C, B
sample = input_sample(); // read L + R samples from ADC7 S" L8 X3 X% P5 _* U0 D
output_sample(sample); // write L + R samples to DAC 9 V% J# F! @! u, c2 x. p
return;7 I8 J% L0 r; e$ @) H% E
}; S* x( x7 q6 l: L" R* `
- Q# y( f8 `* L, W% m3 c3 ]- Aint main( void )
% s8 q: j# k4 |, Z$ |4 L{- H% X$ K6 a: Y2 a
( h0 w2 U9 H# j! Q% y4 f' ? /* Initialize BSL */1 d2 c' U o2 b# H! n
EVMC6747_init( );. l5 d4 l. A0 E& Z
/* Call evmc6747_intr function */
* E5 B4 k) S$ r8 `) E4 s$ V aic3106_init( );
% K% U1 ~) L! d, X! b% ^ while(1);
2 b( C+ I! Q% g4 x' E) b}
9 Y9 J$ @: g0 ` P. X, j& A( f- g$ T, A/ o1 G+ @
C! F3 H$ l( U, y" X. gaic3106_init文件的一部分,McASP配置部分,采用内部时钟,I2S方式,同步传输。音频芯片的配置应该没问题
8 Z+ l* {5 N) A0 ?' i5 b/* Initialize MCASP1 */
3 x! T& q [# x( @ mcasp = &MCASP_MODULE_1;& i# }" _$ V5 P- g
mcasp->regs->GBLCTL = 0; // Reset/ w9 d) l$ k* m' ~, n7 G
mcasp->regs->RGBLCTL = 0; // Reset RX" x; ^! w7 P" g' x8 ~2 S
mcasp->regs->XGBLCTL = 0; // Reset TX
" o: n* K3 \9 ]% Q, t mcasp->regs->PWRDEMU = 1; // Free-running
4 y/ R) ]0 d7 R // configure McASP0 receive registers
) ]- i* L, T: V! B" V mcasp->regs->RMASK = 0xFFFFFFFF; // No padding used Q6 K( o5 H% t& @# A* }; i
mcasp->regs->RFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus9 U: u- b6 X" x2 F) d) J# `6 T' a- V
mcasp->regs->AFSRCTL = 0x00000112; // 2TDM, 1bit Falling, External FS, word+ Z7 ]! | [- m7 {# w
mcasp->regs->ACLKRCTL = 0x000000AF; // Rising INTERNAL CLK,(from tx side)
; y! v, p" q5 G, ?7 @ } mcasp->regs->AHCLKRCTL = 0x00000000; // INT CLK (from tx side)
2 p/ n# I# o$ ] mcasp->regs->RTDM = 0x00000003; // Slots 0,1. }4 y [9 q+ _. j
mcasp->regs->RINTCTL = 0x00000000; // Not used4 ?( g2 p8 W6 Z! q: q$ E- a
mcasp->regs->RCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256& e6 T1 p: ?9 b5 k- V
" n% D1 a9 w# b2 T+ X% Y
mcasp->regs->XMASK = 0xFFFFFFFF; // No padding used
8 E' Z8 W' O3 S% z( g: H- g( k! K mcasp->regs->XFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus4 z4 O' k: A/ o# j0 J
mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word. K4 O& m* J# J; O- r
mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-16* {' H1 Z3 T/ e+ O1 A3 E7 O
mcasp->regs->AHCLKXCTL = 0x00000000; // EXT CLK3 Y4 u* L- {) p1 l
mcasp->regs->XTDM = 0x00000003; // Slots 0,18 S' P$ J9 s1 _8 L3 y9 r9 k5 L
mcasp->regs->XINTCTL = 0x00000020; // interrupt on transmit
$ W' U/ _3 O; v8 c s mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256
- k5 }+ k; b# [3 p2 H
c; _& S! W; m" k, \3 | mcasp->regs->SRCTL5 = 0x000D; // MCASP1.AXR1[5] --> DIN
( c1 I$ s% Z4 I! j0 m9 s/ _4 K& D+ U mcasp->regs->SRCTL0 = 0x000E; // MCASP1.AXR1[0] <-- DOUT
+ B: U! A1 U3 _ mcasp->regs->PFUNC = 0; // All MCASPs
- x: @1 d3 ]) _* R5 M5 L mcasp->regs->PDIR = 0x14000020; // All inputs except AXR0[5], ACLKX1, AFSX1
: h" L% v- s" g, f4 Y0 f6 A' s' H7 {0 H7 l M
mcasp->regs->DITCTL = 0x00000000; // Not used+ V6 g0 t9 Z' \5 ?/ w
mcasp->regs->DLBCTL = 0x00000000; // Not used
p: I n. h0 A9 o/ s; E0 L* h. @% f mcasp->regs->AMUTE = 0x00000000; // Not used" H4 j+ l6 v/ Z- }8 P9 {
. O" D& d2 O9 [. S5 n
/* Starting sections of the McASP*/& b( Z9 C" w/ S- F; O$ M
mcasp->regs->XGBLCTL |= GBLCTL_XHCLKRST_ON; " C+ { N" T% I- d, P4 l( D
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XHCLKRST_ON ) != GBLCTL_XHCLKRST_ON );
5 H9 T3 r5 R+ m. f, s1 @4 | mcasp->regs->RGBLCTL |= GBLCTL_RHCLKRST_ON; ! f9 @- j5 G6 m9 _1 D
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RHCLKRST_ON ) != GBLCTL_RHCLKRST_ON );0 Z' j5 f; P* m1 E/ ~! J; @: H
8 l' y# R6 `" ?* Y: J! _ mcasp->regs->XGBLCTL |= GBLCTL_XCLKRST_ON; % n w/ \# l* {$ Q' e: F% ~2 V
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XCLKRST_ON ) != GBLCTL_XCLKRST_ON );* K% B& s' U. s: e% i* ?
mcasp->regs->RGBLCTL |= GBLCTL_RCLKRST_ON;
@7 Y% X! S3 W+ D while ( ( mcasp->regs->RGBLCTL & GBLCTL_RCLKRST_ON ) != GBLCTL_RCLKRST_ON );- K0 W7 B& W6 i- u6 t
% ^; _+ H; \# c/ N& q' C0 y) Z) C4 o mcasp->regs->XSTAT = 0x0000ffff;
3 k- F! g% S z mcasp->regs->RSTAT = 0x0000ffff;
+ K; j) U' g$ J8 v2 C7 [. K
* l) `% E6 i. {; ^ mcasp->regs->XGBLCTL |= GBLCTL_XSRCLR_ON;
/ t, m* l4 k* X6 Y. F+ S while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSRCLR_ON ) != GBLCTL_XSRCLR_ON );7 s- p# U$ x W5 A% z: S: m/ b
mcasp->regs->RGBLCTL |= GBLCTL_RSRCLR_ON;
2 F G7 Y3 f$ b \3 H while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSRCLR_ON ) != GBLCTL_RSRCLR_ON );% Q& e+ J# D- I' x, \
) o$ a6 a# e' K7 A- H
/* Write a 0, so that no underrun occurs after releasing the state machine */4 _ u3 b9 P+ \) x" y9 C. J
mcasp->regs->XBUF5 = 0;
$ C% V$ o; i) J9 k8 |& S2 q3 d9 T mcasp->regs->RBUF0 = 0;
/ z# @6 M8 w/ R/ i2 K3 G2 \% U* @" n O4 t
mcasp->regs->XGBLCTL |= GBLCTL_XSMRST_ON; 8 M7 X; b! o3 O9 z4 ?
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSMRST_ON ) != GBLCTL_XSMRST_ON );9 q" ?, K& P; Z- Y
mcasp->regs->RGBLCTL |= GBLCTL_RSMRST_ON; b. O6 I. J; a- G
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSMRST_ON ) != GBLCTL_RSMRST_ON );
( _( F: e* @% }" u3 G9 A4 |
7 R, j2 E. \4 \" v: j mcasp->regs->XGBLCTL |= GBLCTL_XFRST_ON; O. D' Y* f4 [; m" g: Q' m( h1 T
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XFRST_ON ) != GBLCTL_XFRST_ON );/ ~' R- l. O5 Q: v: }) S0 L
mcasp->regs->RGBLCTL |= GBLCTL_RFRST_ON;
7 m% T# U$ O+ V3 J* ^0 c8 ~* t7 a while ( ( mcasp->regs->RGBLCTL & GBLCTL_RFRST_ON ) != GBLCTL_RFRST_ON );
{8 T' n t% ^; Q, W2 I! V5 n: T5 X! X, [
CSR = 0x0000;, M1 r, h5 y% P7 D, G
INTC_INTMUX1 = 0x3d;5 I, R0 x5 _1 V$ F! z4 Z3 s
ISTP = (unsigned int)vectors;
8 i" i6 g0 s$ _ ICR = 0xFFF0;
* M3 P6 @3 \$ J: d4 G IER |= 0x12;
6 U' [- f1 Y9 F" c2 | CSR |= 0x01;
7 o. u y6 M" |% Y) ^; ^; u/ K( U/ y* {" d. s+ a
7 X% ?" I1 b ]; \" n& E5 _& f4 e, d# z
还有就是两个输入输出函数:
1 p$ N: \; E; avoid output_sample(Int32 out_data)# m6 `* t& K! @
{
$ A/ C/ M- U$ U: y AIC31_data.uint = out_data; ! w) P3 `& P2 \0 e; z
MCASP1_XBUF5_32BIT = AIC31_data.uint;
2 ^& t2 d. s1 O* N2 e+ E}: T [5 B; I. W+ V8 Z& w5 q
' N( A& [; c" p8 BInt32 input_sample(void)
& c* [6 t) t$ H4 L{ # E5 J& w f% L$ a5 c4 {3 I4 n
AIC31_data.uint = MCASP1_RBUF0_32BIT;
( L: O# W* L4 L return (AIC31_data.uint);' N( B! }2 o) \0 J+ [) t: n5 ]
}
$ b* w& v/ [0 ]4 p3 y3 F2 j% v. C. ]- F) V& H
|
|