Anda di halaman 1dari 5

Lecture 4 Interrupts


An event that causes processor to halt
What are interrupts? what it is doing, and execute an interrupt
 service routine (ISR)
What is CSL and BSL? 
 Sources of interrupts include:
Using AD535 codec  Timers
 Output sine to DSK codec via serial port External interrupts

DMA (direct memory access)
Using Interrupts McBSP transmit or receive
 Use serial port interrupt to synchronize
sinewave sample output

Interrupts Setting up interrupts



Assign events to CPU
interrupts CCS
Configuration
Associated with each
Create the interrupt Tool
interrupt is an vector table
address in memory

At that memory location Interrupt service routines


is a branch instruction to
the actual ISR (interrupt 1. Save registers
vector table) (context save)
Interrupt events are Use Dispatcher
mapped to internal 2. Actual function to
CPU interrupts perform in Configuration
Tool
3. Restore registers
(context restore)

Enabling interrupts TI Software Foundation Libraries



Individual interrupts can be turned Board Support Library (BSL)
on or off (set appropriate bits in Higher-level routines supporting DSK-specific functionality
Interrupt Enable Register) BSL routines make use of CSL routines


A master switch can be used to turn bsl_ad535.h Chip Support Library (CSL)
all interrupts on or off (Global Enable bsl_led.h Low-level routines supporting on-chip peripherals

Interrupt bit in the Control Status bsl_dip.h


... mcbsp.h
Register) edma.h C Compiler
irq.h Runtime Support Library
Standard ANSI C libraries
...
stdio.h
These are defined in irq.h in the Chip Support math.h TI DSP
Library (CSL) ...
Peripheral Support Libraries General Procedure to use BSL/CSL
1. Declare variables
[]\ =E(  ,.3  -( '_^W)( +  U(E(9 *  (
‘C6000 CSL Modules ‘C6711 DSK BSL
           F# F#; (       (
!#" $%&('*) + ,.-'*/ )*' F#QM0C 4 =&'<) + ,.H(9 -
0#!12)3 ' 0 4RS*R 0#))<'=*=?<E-( ;)*-('*)
4 0#5 4 '/ )'*6  -('*&('(-(' -( .)*(&,7 +    4 "$ C#'-?H(9 - 4 " $J=LM  )3 '=
48 0 4  9 ')(:;':(9 ,.)<)'*== @(0#!T$9 (U(9 :V@((0!WCQ 8
1 48 0>1(3(*)<'-- 9 '*):?':(9 ,.*)*)'*== 1 4 IX9   '? 1 4Y =
1 8 " @A1B '9 (*:;':;9 ,? ( '9 + )*'
!$" !(=&(9 ( ( '9 + *)' DSP/BIOS
" C#D " ( '9 9 E&( )  9   '9 !#IJ"Z!#9 -(LM9 '?  '9 9 E&( =
8 #FG$ 8 E(   )*3( '*H(E + + '9 '-;=*'9  *& (9  Example: AD535_Handle myHandle;
$IJCK$(LM'9G-((LM AD535_Config myConfig = {
AD535_LOOPBACK_DISABLE,
5 4 " NO <-(9 -;  ) E- '
AD535_MICGAIN_OFF,
5(" 8 1CP5( :'9 AD535_GAIN_0DB,
AD535_GAIN_0DB };

General Procedure to use BSL/CSL General Procedure to use BSL/CSL


1. Declare variables 1. Declare variables
`a\ =E  ,?3 ( - '_^W)((+  U(E9 *   k]\ =E(  ,.3  -( '_^W)( +  U(E(9 *  (

2. Open peripheral 2. Open peripheral


b C'=*'9 */ '=?9 '= E(9 )*' l C#'=*'9 */ '=.9 '=(E(9 )*'
c $9 / - '=?d 3 -( ' Y  9 '+ '9 ' )'?9 '*=(E9 )' m $9 (/ - '=.d 3 (- ' Y  ;9 '+ '9 ' )'.9 '*=(E(9 )<'
e 0 4R*SR*f  )* " - =_.&9 '6 - '+  '*-;&( ( '9 g
=&'*) +  )*  ,_+ 9h 3('.)(-(')_( 3 ' 4 Gij
3. Configure peripheral
n 0#&(& ,_=' E(&) +  UE(9   ( ;&'9  &(3 '9 

AD535_Handle myHandle; AD535_Handle myHandle;


Example: AD535_Config myConfig = {
Example: AD535_Config myConfig = {
AD535_LOOPBACK_DISABLE, ... }; AD535_LOOPBACK_DISABLE, ... };

main() { myHandle = AD535_open(AD535_localId); main() { myHandle = AD535_open(AD535_localId);


AD535_config(myHandle, &myConfig);

­ 0 U(9   3(:


General Procedure to use BSL/CSL ® C' 6   :;'?'*/<' = Creating a Sine Wave
1. Declare variables ¯ " (        
oa\ =E  ,?3 ( - '_^W)((+  U(E9 *  
A
tvuxw y z {vwG|*}(~G€‚vƒ„…‚<†ˆ‡v‰ ‰v‰vŠ ‰
2. Open peripheral tvuxw y z {vwG| ‹ Œ*‚ƒx„…‚<†_ ‰v‰ ‰Š ‰
p C'=*'9 */ '=?9 '= E(9 )*'
q $9 / - '=?d 3 -( ' Y  9 '+ '9 ' )'?9 '*=(E9 )' z { Žz {vwvwv{‘ ’x“z ux” t
•
y – “x— Ž˜h— ’xw™
z {vŽ*š<›vœ vž™ Ÿ ¡z ¢ wG“xy˜— ’ wGŽ —£x– wG¡ Ÿ
3. Configure peripheral z {vŽ<¤x™
r 0&&( ,.=' E&) (+  U(E(9   ( &('9  &(3('9   Ž — Ž z ¥z {vŽŽ ›v‰™

4. Use peripheral Ÿ¡¡


s (:.
' &('9  &3 Y =_E(=*'.+ E )   =. 9 '-7 LM9   '. 3 ': ¦ “uwhy § “<¨©€v—£GhŽ “vw{vw§ — Ž w
z { wG˜h— ’xwz ª w§ w
AD535_Handle myHandle; ¡¡Ÿ Sine_gen.c
Example: Generates a value
AD535_Config myConfig = { § w Ž «§ {x‘ ‘ z {vŽ ” ‘  œv‰ ‰ ‰v¡ ˜— ’vwv” ” ™ for each output
AD535_LOOPBACK_DISABLE, ... }; ¬ sample
main() { myHandle = AD535_open(AD535_localId);
AD535_config(myHandle, &myConfig);
AD535_write(myHandle, value);
Output Sine via AD535 Codec Send to Codec via McBSP
DSK DSK
‘C6711 ‘C6711

sineGen °±²
AD535 sineGen McBSP °±²
AD535

· (AD535
 )*'?3 (' 
Codec McBSP Block Diagram
McBSP0
¸¹º ³´µ ¶ RINT
DXR
XSR XINT
¹¸º ³´µ ¶
RSR
DRR CPU
D R
Fs = 8KHz R Expand B RSR DR
P (optional)
e R R 32
CLKR
r
CLKX i
p D Compress
clock h X (optional) XSR DX
4  .#3(*(' e R
AD535 BSL r
0 4RS*Rf (+  U»= 9 E()* E(9 '.E =*'- ;)((+  U E(9 '.0 4¼RS*R & 9 :;'* '9 = a
=E)3?=? (&E( 7  E( &E( U  =g*' )½ l CLKR
0 4RS*Rf !(-( '¾E='-? 9 '<+ '9 '*()*'. 3 '?0 4¼RS*R  ) -(' B
u
CLKX
0 4RS*Rf (&Sample
'*(e j29 '=*'rate
9 /*'=.9 '<is=hard-wired
E(9 )'.(-9 ' E(9  to
=.3*8(-(kHz
' s McBSP Control
CLKS
0 4RS*Rf )((+  U(e j¿)(+  U E(9 '<=?0 4#R<SR (- 8 )F¼$GÀ DMA Registers
FSR
REVT
0 4RS*Rf 9 '*-e jÁ9 '- =.+ 9 (:V0 4¼RS*R 0 4 W 3(9 E 8 )F#G$À.9 ')*' /*' FSX
XEVT
0 4RS*Rf LM9   'e jaLM9   '=. ;0 4#R*SR.4 0#Â 39 E 8 )F¼$GÀ? 9 (=: 

AD535_write Synchronizing the Output Samples


A
DSK
‘C6711 Algorithm t
sineGen
Generates a single
AD535 BSL
sine sample
sineGen McBSP °±²
AD535

Timing sineGen sineGen

Ë How often should


we output a sample? 125µS
)(-('*)QME( e j Ê Since sineGen is faster than 1 µs
McBSP AD535
à 0 4RS*Rf LM9   'e 3 (- 'g*=  'ÄM' e j j Å how do we wait another 124+ µs? ÇÈGÉ
Æ

McBSP transmit interrupt


Ì 0 U(9   3:
Í C' 6   :'.'*/*'( = Real-time Sync to XINT0 Turning Function into an ISR
Î "         
DSK
‘C6711
HWI AD535 BSL
sineGen McBSP °±²

McBSP transmit interrupt


(XINT0)

"  '9 9 E&(h'9 / )'_C#(E(   ' " ( '9 9 E(&(G'9 / )'_CE(  ('
)//
(-('*) f (E e j )//
-('*) f (E( e j
à 0 4RS*Rf LM9   'e 3 (- 'g*=  'ÄM' e j j Å Ã 0 4RS*Rf LM9   'e 3 -( 'g*=  'ÄM' e j j Å Note underscore
Æ Æ before C function
name

Ï 0 U(9   3: Õ 0 U(9   3(:


Ð C' 6   :'.'*/*'( = Codec Initialization Ö C' 6   :;'?'*/<' = Codec Initialization
Ñ "          × " (        
DSK /* BSL bsl_ad535.h */ DSK
AD535_Handle hAD535;
AD535_Config myAD535 = {
‘C6711 ‘C6711
AD535_LOOPBACK_DISABLE,
HWI AD535 BSL HWI AD535_MICGAIN_OFF,
AD535 BSL
sineGen McBSP °±² sineGen AD535_GAIN_0DB, McBSP °±²
AD535_GAIN_0DB };

transmit interrupt void codec_init()


transmit{interrupt
/* BSL bsl_ad535.h */
: e j :; (e j
hAD535 = AD535_open(AD535_localId);
à  f " (  e j ÅV7 ÒG)= ½ 3Ò 7 à # f "   e j Å
AD535_reset(hAD535);
F f  (  e j ÅV7 ÒGH(= ½ 3Ò 7 F# f    e j Å
AD535_config(hAD535, &myAD535); }
)-('*) f  (  e j Å
Defined in bsl6711dsk.lib
)(-('*) f (E e j
LÓ3  'e Ôj Å Ã 0 4RS*Rf LM9   'e 3 0 4#R<SR g<= '/*Ä#HWI
'e j j */Å LM3(  'e Ôj Å )-('*) f (E( e j (included in Linker:Options)
Æ Æ Æ Ã 0 4RS*Rf LM9   'e 3 0 4R*SR g<= ('/*ÄÓHWI
'(e j j */Å
Æ

Ø 0 U(9   3:


Ù C' 6   :'.'*/*'( = Enabling Interrupts Enabling Interrupts
Ú "         
DSK IFR IER CSRGIE
Interrupt “Individual “Master
‘C6711 Occurs Switch” Switch”
INT4 1
HWI AD535 BSL
Û Ü;ÝGÞhÞÞ
sineGen McBSP °±²
0 Ü;߈à
INT15 1
transmit interrupt
: e j
à  f " (  e j Å
F f  (  e j Å Interrupt Enable Reg (IER)
turns on individual
)(-('*) f    e j Å interrupts
 (  f !IX" e j Å IRQ_enable(INT) GIE bit in Control Status Reg (CSR)
)(-('*) f (E e j enables all enabled interrupts
LÓ3  'e Ôj Å Ã 0 4RS*Rf LM9   'e 3 0 4#R<SR g<= '/*Ä#HWI
'e j j */Å HWI_enable(void)
Æ Æ
á 0 U(9   3: ç 0 U(9   3(:
â C' 6   :'.'*/*'( = Enabling Interrupts è C' 6   :;'?'*/<' = Enabling Interrupts
ã "          é " (        
DSK DSK
‘C6711 ‘C6711
HWI HWI
sineGen
C#':':;H'9 g*LM'.E =*'-!IX"ä?+ McBSP
(9 8 )F¼$X 9 °  ± ² =*:  (e å" N#5 Àj sineGen McBSP °±²
//
" C#D f 8 *&(e " C#D f 1 · 5 f å " N5 Àg*äj Å7 ÒG¼ 9 æ(½ 3Ò 7
" C#D f 1 (H( '*e " CD f 1 · 5 f å" N¼5Àj Å
1H( '? transmit
 '9 9 E(&( =_interrupt
U (H  ,?e  3( =?=*' =? 3 '.ÄM" 1©H( ( #C¼j transmit interrupt
: e j //
!IX" f '(*H( 'e j Å;7 ÒG0$"*+ E ()  ((g*#((+  U;5(<Ò 7 :; (e j
à  f " (  e j Šà # f "   e j ŠQME( &E(.=*:&( '. ;=* 9 (U ' '9   (U ( '9 9 E(&( =
F f  (  e j Å F# f    e j Å //
)(-('*) f    e j Å )-('*) f  (  e j Å
 (  f !IX" e j Å  (  f !#IJ" e j Å
0 4RS*Rf LM9   'e 3 0 4#R<SR g<Àj Å )(-('*) f (E e j 0 4RS*Rf LM9   'e 3 0 4R*SR g<Àj Å )-('*) f (E( e j
LÓ3  'e Ôj Å Ã 0 4RS*Rf LM9   'e 3 0 4#R</*SR XINT0_HWI
g<= 'Ä#'e j */j Å LM3(  'e Ôj Å Ã 0 4RS*Rf LM9   'e 3 0 4R*/*SR XINT0_HWI
g<= ('ÄÓ'(e j */j Å
Æ Æ Æ Æ

Anda mungkin juga menyukai