|
| _atomic_| Summary | |
#include <intrins.h>
void _atomic_ (
unsigned int n); /* number of instructions to protect */
| | Description | | The _atomic_ routine allows you to protect a number of instructions from hardware interrupts. When you use this function, the C166 Compiler inserts an ATOMIC instruction into your program. The argument n specifies the number of instructions to protect (1-4). If a value of 0 is used for n, the _endatomic_ function must be used to terminate the atomic sequence. The compiler automatically calculates the number of instructions protected from interrupts. Note - Typically, you should use _atomic_(0) to begin an atomic sequence and _endatomic_() to terminate the sequence. This process automatically generates the correct atomic length.
- The _atomic_ and _endatomic_ routines may be used only when the MOD167 control is specified because the ATOMIC instruction is available only in the C167 instruction set.
| | Return Value | | None. | | See Also | | _endatomic_ | | Example | |
1 #pragma MOD167
2 #include <intrins.h>
3
4 int i;
5
6 void main (void) {
7 _atomic_(0); /* compiler calculates 'n' */
8 i = i + 10;
9 _endatomic_(); /* terminate _atomic_(0) */
10 }ASSEMBLY LISTING OF GENERATED OBJECT CODE
; FUNCTION main (BEGIN RMASK = @0x0010)
; SOURCE LINE # 6
; SOURCE LINE # 7
0000 D110 ATOMIC #02H
; SOURCE LINE # 8
0002 E0A4 MOV R4,#0AH
0004 04F40000 R ADD i,R4
; SOURCE LINE # 9
; SOURCE LINE # 10
0008 CB00 RET
; FUNCTION main (END RMASK = @0x0010)
|
Related Knowledgebase Articles |
|