| ||||||||
Technical Support On-Line Manuals C166 User's Guide | Using InterruptsTo enable an interrupt source you must set the following registers:
Use the following methods to disable interrupts for a C statement or a C function:
The following example program shows the C statements required to disable interrupts:
stmt level source
1 #include <reg167.h>
2 #include <intrins.h>
3
4 long l;
5
6 void test (void) {
7 1 _bfld_ (PSW, 0xF000, 0xF000); /* disable interrupts */
8 1 _nop_ (); /* avoid pipeline effect */
9 1 _nop_ ();
10 1 l = 0;
11 1 _bfld_ (PSW, 0xF000, 0x0000); /* enable interrupts */
12 1
13 1 _atomic_ (0); /* disable interrupts */
14 1 l = 1;
15 1 _endatomic_ (); /* enable interrupts */
16 1 }
17
18
ASSEMBLY LISTING OF GENERATED OBJECT CODE
; FUNCTION test (BEGIN RMASK = @0x4010)
; SOURCE LINE # 6
; SOURCE LINE # 7
0000 1A88F0F0 BFLDH PSW,#0F0H,#0F0H
; SOURCE LINE # 8
0004 CC00 NOP
; SOURCE LINE # 9
0006 CC00 NOP
; SOURCE LINE # 10
0008 F68E0000 R MOV l,ZEROS
000C F68E0200 R MOV l+02H,ZEROS
; SOURCE LINE # 11
0010 1A8800F0 BFLDH PSW,#0F0H,#00H
; SOURCE LINE # 13
0014 D120 ATOMIC #03H
; SOURCE LINE # 14
0016 E014 MOV R4,#01H
0018 F6F40000 R MOV l,R4
001C F68E0200 R MOV l+02H,ZEROS
; SOURCE LINE # 15
0020 CB00 RET
; FUNCTION test (END RMASK = @0x4010)
Note
| |||||||
| ||||||||