|
|
C6747和C6748感觉差不多,我想实现McASP发送中断方式控制音频信号,在轮询的例程基础上改的,轮询程序可以实现,但是中断一直实现不了,也找不到错误,求大神帮忙!下边是主要程序:
' Q B' K* d l$ \+ I& ]main文件:
4 Q: T1 t! i7 O9 }' F cinterrupt void interrupt4(void) 9 ?+ z% T/ ] |* q
{
3 _3 d; m0 b, z% l Uint32 sample;0 t" L$ J7 L! d( A
% m$ U0 d. c- L7 o
sample = input_sample(); // read L + R samples from ADC, v0 G; @0 y! u0 H# `% [' A e$ x
output_sample(sample); // write L + R samples to DAC ! I. X* B) i8 b/ _
return;
" E: e* T. G$ u3 }7 Z" X; Z}4 p1 a: r3 H& o, y! w
4 i1 z# U- r9 t! Gint main( void )
, V9 _3 z( [1 Q9 `6 f{+ J- Q$ c" A0 r: d
3 ]0 G/ {" {5 B
/* Initialize BSL */
& v1 E# |0 `8 b6 D6 ?1 P. M EVMC6747_init( ); L" E' ?0 G/ D2 t
/* Call evmc6747_intr function */
; N" ^4 O9 \+ t9 n2 f. _, N aic3106_init( );) d8 o. \- Q9 O$ v
while(1);% h7 Y& Y" K; B
}9 f" k# r, J9 @0 ]! C9 K
6 o' w& t$ S& z" s: y
* E% n: C- A$ I' o7 N( Y2 Daic3106_init文件的一部分,McASP配置部分,采用内部时钟,I2S方式,同步传输。音频芯片的配置应该没问题2 w+ i& V) V( O1 o
/* Initialize MCASP1 *// B. u+ d. @% O! i
mcasp = &MCASP_MODULE_1;
# v( m& }9 Y: @5 c" @: _, w' g: ? mcasp->regs->GBLCTL = 0; // Reset- C! b \% ^6 ^8 M/ w5 P
mcasp->regs->RGBLCTL = 0; // Reset RX
( I1 V( R1 e* J; A$ Z6 A# h& l) L1 O* b mcasp->regs->XGBLCTL = 0; // Reset TX
6 x: h1 ^" u0 ^; @6 P% L6 N mcasp->regs->PWRDEMU = 1; // Free-running5 |2 Z& C& c; E3 |) V0 F# o9 B' Q
// configure McASP0 receive registers8 ]9 w, V0 ~3 E4 P+ q, [
mcasp->regs->RMASK = 0xFFFFFFFF; // No padding used
! u% ^8 I' B1 O9 ~/ R mcasp->regs->RFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus
: c6 O& M4 o: Z& E7 h3 B' n mcasp->regs->AFSRCTL = 0x00000112; // 2TDM, 1bit Falling, External FS, word4 Y9 Z2 I6 M# y( T; }
mcasp->regs->ACLKRCTL = 0x000000AF; // Rising INTERNAL CLK,(from tx side)
6 `( d+ G2 j% z5 z# F! d: g: n; t mcasp->regs->AHCLKRCTL = 0x00000000; // INT CLK (from tx side)
3 ?/ d d7 P, e' N6 A3 C% ~ mcasp->regs->RTDM = 0x00000003; // Slots 0,1( g a! _( Y3 P. t
mcasp->regs->RINTCTL = 0x00000000; // Not used
9 V: r( A# r6 a5 U4 o4 T! ]% @4 n mcasp->regs->RCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-2563 c" M. w1 I0 [. f
) e6 u+ q. P7 E9 R& o! r( s mcasp->regs->XMASK = 0xFFFFFFFF; // No padding used
% K! Z2 C( D9 C7 Z) f7 w/ b mcasp->regs->XFMT = 0x00018078; // MSB 16bit, 0-delay, no pad, CFGBus
+ b0 }! o% z% K# I% T mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word7 w1 ]/ V$ p8 I4 C8 c2 G
mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-16
7 \. s0 i( |) x5 J" E& Q6 q mcasp->regs->AHCLKXCTL = 0x00000000; // EXT CLK) \" ~+ u: U9 j' o& a/ M) k
mcasp->regs->XTDM = 0x00000003; // Slots 0,1
* A8 G8 m: p9 a mcasp->regs->XINTCTL = 0x00000020; // interrupt on transmit$ [5 g, ?, I+ N/ @
mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256' w l( d! j0 P+ K* R- U
+ d* C% w9 ^) i- c' e
mcasp->regs->SRCTL5 = 0x000D; // MCASP1.AXR1[5] --> DIN
! h# a6 K5 p, Q' c) f% e9 b mcasp->regs->SRCTL0 = 0x000E; // MCASP1.AXR1[0] <-- DOUT
4 h' i+ S# o1 @" W; U# M/ |9 g mcasp->regs->PFUNC = 0; // All MCASPs8 f4 q) Y# ]+ }; i
mcasp->regs->PDIR = 0x14000020; // All inputs except AXR0[5], ACLKX1, AFSX1* h6 R' i; }+ u/ x; }" b
" l! {+ x7 G% D mcasp->regs->DITCTL = 0x00000000; // Not used
7 j& c: B) V' @: x mcasp->regs->DLBCTL = 0x00000000; // Not used
6 I/ J1 `: }; w mcasp->regs->AMUTE = 0x00000000; // Not used" L0 L+ L9 O+ A& K
& H6 ?) J# a. `' H' t: A/* Starting sections of the McASP*/
7 l9 r; w J" k t* n' {6 U/ Q4 C mcasp->regs->XGBLCTL |= GBLCTL_XHCLKRST_ON; $ T; M+ V7 z' b
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XHCLKRST_ON ) != GBLCTL_XHCLKRST_ON );
1 m# g$ \0 A7 o1 X4 B+ i5 N4 _ mcasp->regs->RGBLCTL |= GBLCTL_RHCLKRST_ON; 6 O7 j% l! G* `
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RHCLKRST_ON ) != GBLCTL_RHCLKRST_ON );7 | x$ s# _8 J7 n u7 z6 \
8 X+ |8 y" L3 {: s4 u mcasp->regs->XGBLCTL |= GBLCTL_XCLKRST_ON; & u# a) ]6 Y" N/ H
while ( ( mcasp->regs->XGBLCTL & GBLCTL_XCLKRST_ON ) != GBLCTL_XCLKRST_ON );
/ `; @; K' S) j, s; {3 n mcasp->regs->RGBLCTL |= GBLCTL_RCLKRST_ON;
) C- z2 D6 _6 [2 q while ( ( mcasp->regs->RGBLCTL & GBLCTL_RCLKRST_ON ) != GBLCTL_RCLKRST_ON );) {8 M/ ^+ p/ P0 Q& ^% W
0 C8 A5 r0 \+ V1 O. q3 ~0 D! A6 g- v
mcasp->regs->XSTAT = 0x0000ffff; 2 y* u4 l; [% [8 x! j
mcasp->regs->RSTAT = 0x0000ffff; 9 G! h" P! S% `1 r7 f
$ o1 u# j; F2 ^$ @: t
mcasp->regs->XGBLCTL |= GBLCTL_XSRCLR_ON;
3 \( _' \4 e7 Z0 P% x while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSRCLR_ON ) != GBLCTL_XSRCLR_ON );
+ x6 S+ I% t+ R/ p4 `0 \ mcasp->regs->RGBLCTL |= GBLCTL_RSRCLR_ON;
& @% L, U+ n6 M. t8 G% N while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSRCLR_ON ) != GBLCTL_RSRCLR_ON );- v* F( J; Y6 E1 v
3 I0 C3 H8 ]: i, C: [( Y: ? /* Write a 0, so that no underrun occurs after releasing the state machine */; j! [; \ T! d. I5 g% A' ~# }9 z; o
mcasp->regs->XBUF5 = 0;! M* ^, q# i- ?# t; Y
mcasp->regs->RBUF0 = 0;
0 {9 m% e# a# H, v; @+ j4 `
" N9 K' N' U! N% A3 l; J mcasp->regs->XGBLCTL |= GBLCTL_XSMRST_ON;
& y0 e0 }3 ]0 b" p9 `* T. `0 e while ( ( mcasp->regs->XGBLCTL & GBLCTL_XSMRST_ON ) != GBLCTL_XSMRST_ON );
8 P k' t7 i8 R+ R mcasp->regs->RGBLCTL |= GBLCTL_RSMRST_ON;
7 O4 B8 z5 s* X. f8 u while ( ( mcasp->regs->RGBLCTL & GBLCTL_RSMRST_ON ) != GBLCTL_RSMRST_ON );6 @: e5 T' O* }- j: z- s
* R" ?7 H; Q0 Q1 u8 L1 O mcasp->regs->XGBLCTL |= GBLCTL_XFRST_ON;
% K* d$ ]$ h2 f( I; J while ( ( mcasp->regs->XGBLCTL & GBLCTL_XFRST_ON ) != GBLCTL_XFRST_ON );
; [( {6 L5 w* k# {' U1 P# E5 I mcasp->regs->RGBLCTL |= GBLCTL_RFRST_ON; - y9 l/ d' s8 e6 U
while ( ( mcasp->regs->RGBLCTL & GBLCTL_RFRST_ON ) != GBLCTL_RFRST_ON );
4 B, a4 D4 _& M/ U5 s6 o5 O! p3 M' u& l8 t; T
CSR = 0x0000;+ G1 x+ w! M7 e' M, C1 G- s
INTC_INTMUX1 = 0x3d;2 w2 [" ?6 @1 |+ h# D; r4 S
ISTP = (unsigned int)vectors;
6 q$ V( j# R/ Y& y X" \8 X2 i ICR = 0xFFF0;
( M1 A6 T: p2 o6 b& Y: {; d' l8 b& Z IER |= 0x12; 5 S) A9 n2 L* \0 Y. X! N0 `
CSR |= 0x01;
7 P& n: p2 S3 A3 |8 t! e3 D' s. F0 b( h3 @
# T2 L) } N! Z: t- ?3 p; a- [8 V
" Y8 V6 {8 Q+ F还有就是两个输入输出函数:1 C7 _4 r5 a" `& ~8 [
void output_sample(Int32 out_data)+ D4 l* R7 }" q- r! o
{2 v! v3 E1 Y' Q1 l0 ]( N
AIC31_data.uint = out_data; 8 Q( e1 u8 E% Y( n; f: _ V
MCASP1_XBUF5_32BIT = AIC31_data.uint;4 X4 K; x9 Z- j7 A0 ~. R8 i7 W* N6 f
}
. R7 A! r* T k! ^" e# d2 ]5 }
8 o0 R8 f0 @: b3 a' QInt32 input_sample(void)
: W- o7 M% S# X# c{
0 o( A$ C$ A/ A$ H' J: ^( _ AIC31_data.uint = MCASP1_RBUF0_32BIT;# ~5 r% j1 N* Q: J% o8 M
return (AIC31_data.uint);
, G K4 b' h! `) x5 j}
$ G7 I6 H! \ M$ G ?2 K
7 w8 E& S/ c$ o2 Z4 _) o |
|