|
|
C6747和C6748感觉差不多,我想实现McASP发送中断方式控制音频信号,在轮询的例程基础上改的,轮询程序可以实现,但是中断一直实现不了,也找不到错误,求大神帮忙!下边是主要程序:) Z4 i$ C F% F
main文件:
3 E7 O6 I* i; H2 finterrupt void interrupt4(void)
! I+ L0 F H0 h9 ]" @{
H7 A+ f8 B, w+ M5 |4 B Uint32 sample;/ H7 j. I$ U9 j6 t6 Y. f. c
; `; i; |. h4 u! A, A
sample = input_sample(); // read L + R samples from ADC4 m# w5 S, E. k1 z
output_sample(sample); // write L + R samples to DAC 9 X" \% |" Z1 B' L4 R& R$ ~4 h
return;
1 d' e+ U4 V: {) T% D}
1 `9 ]* O, I+ f. A/ D
P. `% c! c: g+ W' b8 _$ z' G( iint main( void )" Y6 G3 M0 K' A. U' F4 S
{
3 |3 S6 _' k1 L! @' q( E6 C$ f7 t" A8 e0 G* \/ C/ ?9 d
/* Initialize BSL */
) j: a* N8 Y; v& m0 r, K EVMC6747_init( );
* z. ^: L3 S$ N0 P4 q+ `4 h /* Call evmc6747_intr function */
/ J4 h3 X1 ^/ L4 I+ M6 R8 f, x aic3106_init( );
% D* H/ c* l! q' T while(1);' d. s2 Z& O- [/ {
}6 R2 \% m" [) a7 v$ [- J7 j- V
5 C" z; _5 r! u9 `
g% f% ^$ s3 Y& m" t5 G+ I0 ^aic3106_init文件的一部分,McASP配置部分,采用内部时钟,I2S方式,同步传输。音频芯片的配置应该没问题
! x/ l7 `* H- A0 r/* Initialize MCASP1 */
/ b; k- c' g9 ` mcasp = &MCASP_MODULE_1;
; Y3 X1 f4 e; {* M2 N mcasp->regs->GBLCTL = 0; // Reset
! L3 E1 R9 Q, s f5 `" g. D: u mcasp->regs->RGBLCTL = 0; // Reset RX
" B2 ~1 y% Q, R' q6 j mcasp->regs->XGBLCTL = 0; // Reset TX
8 Y1 `1 n9 n1 S. p mcasp->regs->PWRDEMU = 1; // Free-running1 k: \7 Z! |, h B8 j, ]
// configure McASP0 receive registers
1 l6 q3 w+ M$ U! M9 c1 m8 P* S* J mcasp->regs->RMASK = 0xFFFFFFFF; // No padding used! |7 y. B) o6 M6 F4 [' s: o
mcasp->regs->RFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus: L' c# d5 Q, h* y! U4 Q8 F [
mcasp->regs->AFSRCTL = 0x00000112; // 2TDM, 1bit Falling, External FS, word3 C4 G7 g+ h! D5 G! g" ?* A, |
mcasp->regs->ACLKRCTL = 0x000000AF; // Rising INTERNAL CLK,(from tx side)$ |( X# E) F$ ?7 b
mcasp->regs->AHCLKRCTL = 0x00000000; // INT CLK (from tx side)* a' R6 \, E3 G. [5 v3 h
mcasp->regs->RTDM = 0x00000003; // Slots 0,1$ W% l3 H8 S" M# T( b
mcasp->regs->RINTCTL = 0x00000000; // Not used. j! N+ w$ B( t: g% b" z# M
mcasp->regs->RCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256
, X/ d9 D3 ?# c3 W
" |+ m! e; d* Y mcasp->regs->XMASK = 0xFFFFFFFF; // No padding used0 d) o T2 P$ Z8 ?4 o
mcasp->regs->XFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus* x/ n; t- E% k& _& T' k: a
mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word
0 d* c2 b) @- w7 s" C mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-16
8 \* E2 b: I3 \: ] mcasp->regs->AHCLKXCTL = 0x00000000; // EXT CLK
- u" ^2 c- _% n _. r& C mcasp->regs->XTDM = 0x00000003; // Slots 0,1& ?+ q# K, Q3 ^' h
mcasp->regs->XINTCTL = 0x00000020; // interrupt on transmit& I9 g+ t8 |* m! M0 _9 _# u
mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256
0 G4 _" H0 z4 Q
6 X. {& a7 ^7 C* [ mcasp->regs->SRCTL5 = 0x000D; // MCASP1.AXR1[5] --> DIN' J+ {- s3 A; w/ z$ e T6 Y
mcasp->regs->SRCTL0 = 0x000E; // MCASP1.AXR1[0] <-- DOUT' E, K4 u0 [7 f4 l3 l
mcasp->regs->PFUNC = 0; // All MCASPs7 Z5 \4 ~' D. y1 ?& t. w6 T$ K! ]
mcasp->regs->PDIR = 0x14000020; // All inputs except AXR0[5], ACLKX1, AFSX1/ I5 P4 {2 q* T) K
% m3 N6 C/ \/ R' R mcasp->regs->DITCTL = 0x00000000; // Not used9 U" e# ]0 N+ p. ]" D d% b
mcasp->regs->DLBCTL = 0x00000000; // Not used
) o8 [( i4 a# ~/ {& H% e mcasp->regs->AMUTE = 0x00000000; // Not used
- u' q3 r! ?6 @. D4 H; J# m8 L
5 E! @3 ?1 @/ Y/* Starting sections of the McASP*/
! b8 ]' P+ v% }2 H: \ mcasp->regs->XGBLCTL |= GBLCTL_XHCLKRST_ON; 6 {8 v g& [8 B) l3 E3 x
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XHCLKRST_ON ) != GBLCTL_XHCLKRST_ON ); # A- T4 |( L; i" I' W: z( z: a0 p
mcasp->regs->RGBLCTL |= GBLCTL_RHCLKRST_ON; 0 \5 W1 P0 @4 m& H
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RHCLKRST_ON ) != GBLCTL_RHCLKRST_ON );1 k+ [9 F, e' `2 I
# s8 g; K- @( T0 s; f
mcasp->regs->XGBLCTL |= GBLCTL_XCLKRST_ON; J" N9 c r% `6 a
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XCLKRST_ON ) != GBLCTL_XCLKRST_ON );
?2 a& v# {( o* M$ A3 S& ~ mcasp->regs->RGBLCTL |= GBLCTL_RCLKRST_ON; 4 h; [# A% u2 V: w* C+ O0 R" N" x
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RCLKRST_ON ) != GBLCTL_RCLKRST_ON ); `6 C& W( X0 s( B# C* W
5 l9 U) Y6 V. L; z) p7 \ mcasp->regs->XSTAT = 0x0000ffff;
8 g% ]/ \& [0 s mcasp->regs->RSTAT = 0x0000ffff; , \7 ^2 d2 r1 B* F1 A5 N8 D
3 z) v) A$ K8 o: s; U mcasp->regs->XGBLCTL |= GBLCTL_XSRCLR_ON;) @4 n7 Z; j8 ~
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSRCLR_ON ) != GBLCTL_XSRCLR_ON );
+ S$ s- n% T7 W( _ mcasp->regs->RGBLCTL |= GBLCTL_RSRCLR_ON;
# ^* G- o6 t9 Q% ` g8 | while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSRCLR_ON ) != GBLCTL_RSRCLR_ON );
8 d+ f$ ]- _0 Y* E% A2 W
7 z- o/ O3 q9 q1 [9 C4 a /* Write a 0, so that no underrun occurs after releasing the state machine */) q3 y, H/ l$ d2 s& R
mcasp->regs->XBUF5 = 0;
0 _' N8 ]. ^7 u) F& k2 N# o4 N mcasp->regs->RBUF0 = 0; g( E0 m' P( t8 C& z, \. [# v7 f
8 r! A0 z8 s8 b mcasp->regs->XGBLCTL |= GBLCTL_XSMRST_ON; * N; p/ L2 c f
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSMRST_ON ) != GBLCTL_XSMRST_ON );
0 ?; M4 Y8 C2 u' H E mcasp->regs->RGBLCTL |= GBLCTL_RSMRST_ON;
- U( N" O5 y( q6 a9 b) ` while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSMRST_ON ) != GBLCTL_RSMRST_ON );
& n* s* |* W( ?$ s' S7 K
7 d2 ]7 E( [1 b mcasp->regs->XGBLCTL |= GBLCTL_XFRST_ON;
( d E! e- {( |' x8 ^3 {$ B. v8 p while ( ( mcasp->regs->XGBLCTL & GBLCTL_XFRST_ON ) != GBLCTL_XFRST_ON );& e9 M P5 ^+ n6 k2 \ k0 p# n
mcasp->regs->RGBLCTL |= GBLCTL_RFRST_ON; 5 a3 t1 a; b. a5 Y; e5 b
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RFRST_ON ) != GBLCTL_RFRST_ON );% ^8 g# Y O/ B7 L, f2 p6 L# p
1 T# @/ H, N C* q& |
CSR = 0x0000;
1 M/ i- q& E. n INTC_INTMUX1 = 0x3d;, G6 m% |# E& e/ D- I: L! n: s4 Z
ISTP = (unsigned int)vectors;
* H: M; j& j! Q. Z/ J) V ICR = 0xFFF0;
7 g+ L5 P& J- B1 I5 M8 C IER |= 0x12;
9 D+ c$ q7 Q. K CSR |= 0x01;
9 P* }% v* |4 V; B$ p+ \( e$ ~
* M+ U- B9 K5 E6 j: ?; [; \8 m' R' s; E
+ \3 Z1 N+ H) `- Q, R# F3 I还有就是两个输入输出函数:) g1 O- f- [' T5 T$ Y. ?
void output_sample(Int32 out_data)
! _8 e" t, D& f1 c& V* s{
, I6 d, z* @# t- _1 j AIC31_data.uint = out_data;
3 E5 w% `- }/ i: o3 X MCASP1_XBUF5_32BIT = AIC31_data.uint;9 S) P# Q+ p @0 M. m L- O+ r
}
: |/ r# ^& v; ^$ |; K, S8 h: W. b" Y* L ?- }
Int32 input_sample(void), H' n' Q5 u3 X# E1 G2 a. v
{
6 P! M9 F1 x2 } AIC31_data.uint = MCASP1_RBUF0_32BIT;
0 x' G- x* L* u6 t' K return (AIC31_data.uint);8 l: c' S" a6 @7 ~: S( l1 |
}
$ e2 Z% i8 X6 z3 x; r/ w/ u# W0 H1 W* q% f4 U& n
|
|