您现在的位置:首页 > 计算机软件及应用 >

最新文档-单片机原理及实用技术 第5章 中断系统及应用-PPT精品文档_图文


5
5
5.1 5.2 SPCE061A 5.3

5

1.

5.1



CPUCPU / CPU

5
2. CPU


5 3.
CPUCPU CPU CPU

5

CPU

CPU

CPU



































5.1

5
4.

(1) ( )
(2) CPU PCSR()

5
(3)
(4) CPU CPU
(5)


5
(6) CPUPCSR CPU


5
5.2 SPCE061A
5.2.1
1.
break FFF5H
2.
CPU SPCE061A PC FFF7H

5
3.
/IRQFIQ
(FIQ) (IRQ)

5

5.2.2

5.1

Fosc/1024 PWMINT TimerA
TimerB
EXT2
EXT1


FIQ/IRQ0 FIQ /IRQ1 FIQ /IRQ2
IRQ3

FFF6H/FFF8H FFF6H/FFF9H FFF6H/FFFAH

_FIQ/_IRQ0 _FIQ/_IRQ1 _FIQ/_IRQ2

FFFBH

_IRQ3

5

4096Hz 2048Hz 1024Hz
4Hz 2Hz TMB1 TMB2 UART

IRQ4
IRQ5 IRQ6 IRQ7

FFFCH
FFFDH FFFEH FFFFH

_IRQ4 _IRQ5 _IRQ6 _IRQ7

5
1.
TimerATimerB 1 0xFFFFH1CPU

5
2.
SPCE061AEXT1EXT2 BIOB2IOB3EXT1(IOB2) EXT2(IOB3) 5.2

5

EXT1 EXT2
()

IOB2 (IOB3)

5.2

5
EXT1EXT2
IOB2IOB4IOB3IOB5 RC5.3 (BIOB2IOB3 IOB4IOB5)IOB4IOB5RC IOB2IOB4(IOB3IOB5)RC EXT1(EXT2) IOB2(IOB3) IOB4(IOB5)

5



1

EXT1

EXT2

( )



IO B2 (IO B3)
R
IOB4 C (IO B5)

5.3 IOB2IOB4IOB3IOB5

5
3.
SPCE061A

5
/ P_UART_Command2TxReady RxReadyCPUCPU P_UART_Command2 TxReadyRxReady TxReadyRxReady B IOB7(RxD)IOB10(TxD)

5
4.
CPUPLL CPU IOAPLL CPU CPUIRQ3_KEY FIQ(TMA)IRQ1IRQ7

5
5.
SPCE061A 32 768 Hz TMB1TMB2 CPU P_INT_Ctrl P_INT_Ctrl

5 5.2.3
1. SPCE061A P_INT_Ctrl
1) P_INT_Ctrl(/)(7010H) P_INT_Ctrl / 5.2

5

5.2





B15

FIQ_Fosc/1024

B14

FFF6H IRQ0_Fosc/1024

B13

FIQ_ TMA

B12

FFF8H IRQ1_TMA

B11

FFF9H FIQ_TMB

B10

FFFAH IRQ2_TMB

Fosc/10241024 A B

5

B9

B8

FFFBH

B7

B6

B5

FFFCH

B4

B3 FFFDH
B2

B1 FFFEH
B0

FFF7H

FFFFH

FFF5H

IRQ3_EXT2 IRQ3_EXT1 IRQ3_KEY IRQ4_4 kHz IRQ4_2 kHz IRQ4_1 kHz IRQ5_4 Hz IRQ5_2 Hz IRQ6_TMB1 IRQ6_TMB2 RESET UART IRQ BREAK

2 2 4096 Hz 2048 Hz 1024 Hz 4 Hz 2 Hz 1 2

5
2) P_INT_Clear ()(7011H)
CPU 1 CPU
P_INT_Clear(5.2 ) 1

5 2.

P_INT_Ctrl () 1
0
-- -- -- --

P_INT_Ctrl () --
--
1 0 -- --

P_INT_Clear () --
--
-- -- 1 0


P_INT_Ctrl ()

5 3.

5.4

FIQ ON FIQ OFF IRQ ON IRQ OFF INT FIQ
INT IRQ
INT FIQ,IRQ
INT OFF


FIQ FIQ IRQ IRQ FIQ IRQ
IRQ FIQ
FIQIRQ
FIQIRQ

5
(1) FIQ ON
FIQFIQ P_INT_Ctrl P_INT_Ctrl FIQ 1CPU FIQ ONFIQ OFF

5

1 FIQ ON _main: FIQ OFF r1 = 0x8000H [P_INT_Ctrl] = r1 FIQ ON loop: NOP GOTO loop

//P_INT_Ctrl FIQ

5 (2) FIQ OFF

FIQ P_INT_Ctrl FIQ

2

_main:

FIQ ON

r1 = 0x8000H

[P_INT_Ctrl] = r1

//FIQ

FIQ OFF

//FIQ

FIQ ON

//FIQ

loop: NOP

GOTO loop

5
(3) IRQ ON IRQ IRQ P_INT_Ctrl FIQ ON P_INT_CtrlIRQ OFF
(4) IRQ OFF IRQ IRQFIQ OFF P_INT_CtrlIRQ ON

5 (5) INT
/FIQ IRQ P_INT_Ctrl
INT INT FIQ FIQIRQ INT IRQ IRQFIQ INT FIQ IRQFIQIRQ INT OFF FIQIRQ

5

3

_main:

r1=0x8004H //IRQ5_2 HzFIQ_PWM

[P_INT_Ctrl]=r1

INT FIQ

//FIQ_PWMIRQ

INT IRQ

//IRQ5FIQ_PWM

NT FIQIRQ //IRQFIQ

INT OFF

//IRQFIQ

loop: NOP

GOTO loop

5 5.2.4
SPCE061A (MCS-8051)5.5
SPCE061A IRQIRQ0IRQ1IRQ1 IRQ2IRQ (UART)

5

5.5 SPCE061A

RESET FIQ IRQ0 IRQ1 IRQ2 IRQ3 IRQ4 IRQ5 IRQ6 UARTIRQ

FFF7 H FFF6 H FFF8 H FFF9 H FFFA H FFFB H FFFC H FFFD H FFFE H FFFF H

0 1 2 3 4 5 6 7 8 9

5
IRQ
FIQ>IRQ0>IRQ1>IRQ2>IRQ3>IRQ4>IRQ5>IRQ6>UART IRQ

5
5.2.5
1.
1)
P_INT_Ctrl P_UART_Command2() P_INT_Ctrl P_INT_Ctrl P_UART_Command2 CPUP_INT_CtrlP_UART_Command2

5
FIQIRQ IRQ0IRQ1IRQ2IRQ3IRQ4IRQ5IRQ6UART 1

5
2)
CPUPCSR PC

5
3) (1) (2) (3) (4)

5 2.
P_INT_Ctrl P_UART_Command2 SPCE061A 1
UART P_INT_Ctrl, UART
P_UART_Command2 1UARTUART P_UART_Command2

5

3.

1) 5.6

RESET FIQ IRQ0 IRQ1 IRQ2 IRQ3 IRQ4 IRQ5 IRQ6 UART IRQ BREAK

FFF7H FFF6H FFF8H FFF9H FFFAH FFFBH FFFCH FFFDH FFFEH FFFFH FFF5H

5








5

.

4
























5
2)
IRQFIQ IRQ FIQ
SPCE061A P_INT_Ctrl 10

5
3)



5 4) SPCE061A CPU P_INT_Ctrl 5)

5 6)
CPU

7)
RETI CPUPCSR

5
5.3
5.3.1
1.
AB FIQIRQ1(TimerA) IRQ2(TimerB) FIQ IRQ

5
4 AAIOA020 ms (10 ms)

(1) FIQIRQ IRQIRQ1_TMAA P_INT_Ctrl IRQ1_TMA
(2) T=20 ms10 msIOA0 10 ms

5 (3) 8 kHz AB1 (4) A(P_imerA_Data) 1/10 ms=100 Hz N=0xFFFF-/
=0xFFFF-8192/100 =0xFFAD

5 5.7

P_TimerA_Data P_TimerA_Ctrl P_TimerB_Data P_TimerB_Ctrl
P_INT_Ctrl P_INT_Clear

/ / / /
/





700A H 700B H 700C H

TimerA
TimerA ClkAClkB APWMO
TimerB

TimerB ClkA 700DH BPWMO

7010 H 7011 H




5
I O A
T im e rA
T i m e r A
5.5

5





.

5



6









IO A 0


























5

TimerA _10ms _Pulse .asm

.include hardware.inc

.define TIMERA_CLKA_8 K 0x0003

//A8192Hz

.define

TIMERA_CLKB_1 0x0030H //B1

.define TIMER_DATA_FOR_8 kHz 0xFFAD

//: 0xFFFFH-/

0xFFFF-8192/100

OxFFAD

.RAM

.CODE

.PUBLIC_main

5

_main:

r1 = 0x0001

//IOA0

[P_IOA_Dir] = r1

[P_IOA_Attrib] = r1

[P_IOA_Data] = r1

r1 = TIMER_DATA_FOR_8 kHz //A0xFFAD

[P_TimerA_Data]=r1 //A8192 HzB1

r1 = TIMERA_CLKA_8K + TIMERA_CLKB_1

[P_TimerA_Ctrl]=r1

r1 = Ox1000

//A

[P_INT_Ctrl]=r1

INT IRQ

//IRQ

loop: NOP

//

GOTO loop

5 A10 msIOA0

.TEXT .PUBLIC _IRQ1 _IRQ1: INT OFF
PUSH r1,r5 TO [sp] r1 = [P_IOA_DATA] r1 ^= 0xFFFFH [P_IOA_Data]=r1 r1=0x1000 [P_INT_Clear]=r1 POP r1,r5 FROM[sp] INT IRQ FIQ RETI

// //
//,
//
// // //

5
2.
SPCE061A2 Hz4 Hz 8 Hz16 Hz32 Hz64 Hz128 Hz256 Hz512 Hz1024 H2048 Hz4096 Hz 5.8

5 5.8

P_TimeBase_Setup P_TimeBase_Clear P_SystemClock
P_INT_Ctrl
P_INT_Clear


/

700EH 700FH 7013H
7010H

TMB1TMB2



7011H

5 5 A8 0.5 s
0.5 s 2 Hz2 Hz0.5 s
IOA0IOA7
2 Hz
TimeBase_2Hz.asm
5.7 5.8

5
8 2 H z
5.7

5





5

.



8







IO A 0 IO A 7





























5

.include hardware.inc .CODE .PUBLIC _main
_main: r1=0x00FF [P_IOA_Attrib]=r1 [P_IOA_Dir]=r1 r1=0x0000 [P_IOA_Data]=r1 r1 =0x0004 [P_INT_Ctrl]=r1 INT IRQ
loop: NOP GOTO loop

//A8
//IRQ5_2 Hz //IRQ

5

IOA0IOA7 LED

.TEXT

.PUBLIC _IRQ5 _IRQ5: PUSH r1,r5 TO [sp]

//

r1 = 0x0004 TEST r1,[P_INT_Ctrl] //2 Hz JNZ IRQ5_2Hz //2 Hz IRQ5_4Hz: r1=0x0008 //4 Hz

GOTO Exit_INT

5

IRQ5_2Hz: Exit_INT:

r1 = [P_IOA_DATA] r1 ^= 0xFFFF [P_IOA_Data] = r1 r1 = 0x0004 [P_INT_Clear]=r1 POP r1,r5 FROM [sp] RETI

//2 Hz //IOA
// // //

5 3.
A8 PC 5.9
6 CPUIOA0 IOA7LED
P_SystemClock b4 A8 A8A 8

5

5.9

P_IOA_Latch P_SystemClock P_INT_Ctrl P_INT_Clear







7004H

A IOA0IOA7



7013H



/ 7010H

: :



7011H



5
A88LED IOA/ 5.9 5.10

5
I O A 0 I O A 7


5.9

5






5

.

10







LED



























5
.include hardware.inc .PUBLIC _main .define P_IOA_latch 0x7004 .CODE _main: r1=0xFF00 //A8, 8 [P_IOA_Dir]=r1 [P_IOA_Attrib]=r1 r1 =0x0000

5

[P_IOA_Data]=r1

r1 =0x0080

//IRQ3_KEY

[P_INT_Ctrl] = r1

r1=[P_IOA_latch]

//A

INT IRQ

//IRQ

r1=0x0007

[P_SystemClock]=r1

//

Loop: NOP

//

GOTO Loop

5

.TEXT

.PUBLIC _IRQ3

_IRQ3:

INT OFF PUSH r1,r4 TO [sp]

//

r1 = 0x0080 test r1,[P_INT_Ctrl]

//

5

jz L_notKeyArouse

//

L_KeyArouse:r1 = [P_IOA_Data] //

r1 |= 0xFF00

//

[P_IOA_Data] = r1

r1 =0x0080

GOTO Exit_INT

L_notKeyArouse:

//

r1 = 0x0100

//EXT1

TEST r1,[P_INT_Ctrl]

5

JNZ L_EXT1

r1 = 0x0200

//2

L_EXT1: NOP

Exit_INT: [P_INT_Clear]=r1 //

POP r1,r4 FROM [sp] //

INT IRQ

RETI

.END

5 4.

SPCE061AEXT1EXT2

IOB2

IOB35.10



5.10





P_INT_Ctrl

/ 7010H

: :

P_INT_Clear

7011H

P_FeedBack

7009H B

5 7 A8LED
EXT1EXT2 EXT1 IOB2EXT2IOB3 EXT1
A8LED
EXT1
Ext1.asm
5.11 5.12

5
I O A 0 I O A 7
EX T1 IO B 2

5.11

5






5

.



12





IR Q _ E X T 1





N ?



Y



LED

























5



.include hardware.inc .CODE .PUBLIC _main _main:
r1=0x00FF [P_IOA_Attrib]=r1 [P_IOA_Dir]=r1 r1 = 0x0000 [P_IOA_Data]=r1 r1=0x0000

//A8 //IOB2

5
[P_IOB_Dir]=r1 [P_IOB_Attrib]=r1 r1=0x0004 [P_IOB_Data]=r1 r1=0x0100 [P_INT_Ctrl]=r1 INT IRQ loop: NOP JMP loop

//IRQ3_EXT1

5 LED

.TEXT

.PUBLIC _IRQ3

_IRQ3:

INT OFF

PUSH r1,r5 TO [sp] //

r1=0x0100

TEST r1,[P_INT_Ctrl] //IRQ3_EXT1

JNZ irq3_ext1

//IRQ3_EXT1

r1=0x0200

TEST r1,[P_INT_Ctrl] //IRQ3_EXT2

JNZ irq3_ext2

5 irq3_key:
r1 = 0x0080 GOTO Exit_INT irq3_ext2: GOTO Exit_INT irq3_ext1: r2=0x00FF [P_IOA_Data]=r2 Exit_INT: [P_INT_Clear]=r1 POP r1,r5 FROM sp] INT IRQ,FIQ RETI

// //2 //1 //LED
//

5
5.
UARTP_UART_Data (/) ($7023H) 5.11

5 5.11

P_UART_Command1
P_UART_Command2 P_UART_Data P_UART_BaudScalar Low P_UART_BaudScalar High P_INT_Ctrl P_INT_Clear


/

7021 H
7022 H


UART
: UART : UART RXTX


/

7023 H

/

7024 H

/

7025 H

/

7010 H 7011 H




5
UART RxTxIOB7 IOB10 UART8

5
8 Fosc=24.576 MHz115.2 kb/s
P_UART_Command1 UART
0000006BH
RxTx 0x1122, 0x33440x55660x77880xAAFF
5.13 5.14

5
I O B 7 , I O B 1 0


5.13

5





.

5

14





N?



?



Y

Y



N ?

N ?



Y

Y









1

1























5


.include hardware.inc

.define UART_DATA_SIZE 0x0005H

.DATA

SendData: .DW 0x1122, 0x33440x55660x7788, 0xAAFF //

.ISRAM

.PUBLIC RecData

//

RecData: .DW 5 DUPdup(0) .var recNum .var sendNum .var sendFlag

// // // 1:8, 0:8

.var recFlag

// 1:8, 0:8

.CODE

.PUBLIC_main

_main:

//

5

r2 = RecData

R1 = 0x0480 //IOB7, IOB10

[P_IOB_Attrib] = R1

R1 =0x0400

[P_IOB_Dir] = R1

R1 = 0x0000

[P_IOB_Data] = R1 R1 = 0x006B

//114.84 kHz(~=115.2 kHz)

[P_UART_BaudScalar Low] = R1

R1 = 0x0000

[P_UART_BaudScalar High] = R1

R1 = 0x00C0

//R1=0000 0000 1100 0000B

[P_UART_Command1] = R1 //

[P_UART_Command2] = R1 // 1.2

5

R1 =0x0000 [sendNum] = r1 [recNum] = R1 R1 = 0x0001 [sendFlag] = R1 [recFlag] = r1 INT IRQ loop: NOP GOTO loop

//0 //0
// // //

5



.TEXT

.PUBLIC _IRQ7

UART_RECC_IRQ:.PROC

_IRQ7:

INT OFF

PUSH r1,r5 TO [sp]

r1 = 0x0080

/RxRDY

TEST R1,[P_UART_Command2]

//

JNZ UART_RECV_IRQ

5
UART_SEND_IRQ: r2 = [sendFlag] r2 ^= 0x0001 [sendFlag] = r2 r1 = SendData r4 = [sendNum] r3 = UART_DATA_SIZE CMP r4,r3 JE exit_INT r1 = r1+r4 r1 = [r1] r2 = [sendFlag]

//
/ // // //

5
JZ Send_Data r1 = r1 lsr 4 r1 = r1 lsr 4 r4 += 1 [sendNum] = r4 Send_Data: [P_UART_Data] = r1 GOTO exit_INT

/8 //1
//

5
UART_RECV_IRQ:
r2 = [recFlag] r2 ^= 0x0001 [recFlag] = r2 r4 = [recNum] r3 = UART_DATA_SIZE CMP r3,r4 JE exit_INT r1 = [P_UART_Data] r2 = [recFlag] JNZ Shift_Data r3 = r4 + RecData [r3] = r1

//
// / //8

5
GOTO exit_INT Shift_Data:
r1 = r1 lsl 4 r1 = r1 lsl 4 r2 = [recNum] r3 = r2 + RecData r4 = [r3] r4 |= r1 [r3] = r4 r2 += 1 [recNum] = r2

//8 //8 //1

5
exit_INT: POP r1,r5 FROM [sp] INT IRQ,FIQ
RETI .ENDP

5
5.3.2
1.
9 IRQ6 IRQ6_TMB1IRQ6_TMB2 1 s0.5 s
IRQ6_TMB18 Hz16 Hz 32 Hz64 Hz0.5 s 64 HzIRQ6_TMB2128 Hz256 Hz 512 Hz1024 Hz128 Hz

5
IOA0IOA7LED IRQ6_TMB1IOA0IOA3LED 1 s1 IRQ6_TMB2IOA4IOA7LED 0.5 s1 5.15 5.16

5
I O A 0 I O A 7 I R Q 6 _ T M B 1 ,I R Q 6 _ T M B 2

5.15

5







5

.



16



IR Q 6 _ T M B 2 ?Y

TM B 2 1



N TM B 1 1



0 .5 s ? N L E D





LED N

1 s ?

Y



LED Y



LED



Y

N

2 s ?

1 s ?

N



Y





































5 .define tmb1clk_8Hz 0x0000 .define tmb1clk_16Hz 0x0001 .define tmb1clk_32Hz 0x0002 .define tmb1clk_64Hz 0x0003 .define tmb2clk_128Hz 0x0000 .define tmb2clk_256Hz 0x0004 .define tmb2clk_512Hz 0x0008 .define tmb2clk_1024Hz 0x000C .define tmb1_clk tmb1clk_64Hz .define tmb2_clk tmb2clk_128Hz .define P_IOA_DATA 0x7000 .define P_IOA_DIR 0x7002 .define P_IOA_ATTRI 0x7003

5 .define P_IOB_DATA 0x7005 .define P_IOB_DIR 0x7007 .define P_IOB_ATTRI 0x7008 .define P_INT_CTRL 0x7010 .define P_INT_CLEAR 0x7011 .define P_Timebase_setup 0x700E .define P_Timebase_clear 0x700F .RAM .VAR TIME1 .VAR TIME2 .CODE .PUBLIC _main

5 _main:
INT OFF r1=0xFFFF [P_IOA_ATTRI]=r1 [P_IOA_DIR]=r1 r1=0x0000 [P_IOA_DATA]=r1
r1=0xFFFF [P_IOB_ATTRI]=r1 [P_IOB_DIR]=r1 r1=0x0000 [P_IOB_DATA]=r1

//IOA //IOB

5

r1=tmb1_clk //TMB164 HzTMB2128 Hz

r1|=tmb2_clk //0000H0003H R1 0003H

[P_Timebase_setup]=r1

r1=0x0003 //IRQ6_TMB1 IRQ6_TMB2

[P_INT_CTRL]=r1

R1=0x0000

[TIME1]=r1

[TIME2]=r1

INT IRQ

loop: NOP

//

NOP

JMP loop

5

IRQ6

.TEXT

.PUBLIC _IRQ6

_IRQ6:

PUSH r1,r5 TO [sp] //

r1=0x0001

TEST r1,[P_INT_CTRL] //IRQ6_TMB2

JNZ l_irq6_tmb2

//IRQ6_TMB2

l_irq6_tmb1:

//IRQ6_TMB1

r2 = [TIME1]

r2 += 0x0001

[TIME1] = R2

CMP r2,64

//1 s

5

JBE LED1_OFF

//LED

r1=[P_IOA_DATA]

r1=0x000F

//LED

[P_IOA_DATA]=r1

CMP r2,128

//

JBE LED1_RET

//LED

r2=0x0000

//TIME1

[TIME1]=R2

JMP LED1_RET

LED1_OFF:

r1=[P_IOA_DATA]

r1&=0x00F0

[P_IOA_DATA]=r1

5

LED1_RET:

//IRQ6_TMB1

r1=0x0002

[P_INT_CLEAR]=r1

POP r1,r5 FROM [sp]

RETI

l_irq6_tmb2: r2=[TIME2] r2+=0x0001 [TIME2]=R2 CMP r2,64 JBE LED2_OFF

//0.5 s //LED

5

r1=[P_IOA_DATA] r1=0x00F0 [P_IOA_DATA]=r1 CMP r2,128 JBE LED2_RET r2=0x0000 [TIME2]=R2 JMP LED2_RET

//LED
//1 s //LED //TIME2

5
LED2_OFF: r1=[P_IOA_DATA] r1&=0x000F [P_IOA_DATA]=r1

LED2_RET:

r1=0x0001

//IRQ6_TMB1

[P_INT_CLEAR]=r1

POP r1,r5 FROM [sp]

RETI

5 2.
10 1 s0.5 s
IRQ2B0.5 sIRQ4 IRQ_1 kHz1 s
IOA0IOA7LEDIOB0IOB7LED
B0.5 sBLED 1024 Hz1 sALED
5.17 5.185.19

5



I O A 0 I O A 7



5

.

I O B 0 I O B 7

17



B





1024 H z B







5






5

.

18








LED

B























5





5

.

19









IR Q 4 _ 1 K ?



10

Y

24

Hz

LED N






















5



.include hardware.inc

.define RUN_TIMERB 0x0400

//

.define TIMER_DATA_FOR_4 kHz (0xFFFF-2048) //0.5 s

.define RUN_TIMEBASE_1024 0x0010 //1024 Hz

.define TIMER_CLKA_4096 0x0004 //A4096 Hz

.RAM

//IOA_LEDB

.VAR clock_cnt

//

.CODE

.PUBLIC _main

_main:

INT OFF r1=0xFFFF

//A

5
[P_IOA_Attrib]=r1 [P_IOA_Dir]=r1 r1=0x00FF [P_IOA_Data]=r1 r1=0xffff [P_IOB_Attrib]=r1 [P_IOB_Dir]=r1 r1=0x00FF [P_IOB_Data]=r1 r1 = TIMER_DATA_FOR_4 kHz [P_TimerB_Data]=r1

//B //B

5

r1 = TIMER_CLKA_4096

//A4096 Hz

[P_TimerB_Ctrl]=r1

r1 = RUN_TIMEBASE_1024 + RUN_TIMERB

//B1024 Hz

[P_INT_Ctrl]=r1

INT IRQ

//IRQ

loop: NOP

//

GOTO loop

5

BBLED 0.5 s

.TEXT

.PUBLIC _IRQ2

_IRQ2:

PUSH r1,r5 TO [sp]

//

r1=[P_IOB_Data]

//LED

r1 ^= 0xFFFF

[P_IOB_Data]=r1

r1=0x0400

//

[P_INT_Clear]=r1;

POP r1,r5 FROM [sp];

RETI

5

1024 HzIOA0IOA7LED 1 s

.TEXT

.PUBLIC _IRQ4

_IRQ4:PUSH r1,r5 TO [sp]

//

r1=0x0010

TEST r1,[P_INT_Ctrl]

//1 kHz

JNZ l_irq4_1k

//

r1=0x0020

TEST r1,[P_INT_Ctrl]

//2 kHz

JNZ l_irq4_2k

//

5

l_irq4_4k:

//4 kHz

r1 = 0x0040

l_irq4_2k:

GOTO exit_int
GOTO exit_int l_irq4_1k: r1 = [clock_cnt] CMP r1,1024 JE LED_pro r1 += 1 [clock_cnt] = r1 r1 = 0x0010 GOTO exit_int

5

LED_pro: r1 =[P_IOA_DATA] r1 ^= 0xFFFF [P_IOA_DATA]=r1 r1 = 0x0000 [clock_cnt] = r1 r1 = 0x0010
exit_int: [P_INT_Clear] = r1 POP r1,r5 FROM [sp] RETI

//P_IOA_DATA LED //

5

1. SPCE061A
2. SPCE061A
3. P_INT_Ctrl
4. SPCE061A
5. AIOA810 ms

5 6. B1 s IOA0
7. 30 s IOA12 s
8. 0x01000x0200 PCFosc=24.576 MHz48 000 b/s
9. PC100 0x1000Fosc=24.576 MHz =115.2 kb/s



热文推荐
友情链接: 简历 面试求职范文 职业规划 自我管理 社交礼仪 76242百科