Download Print this page

Siemens AP164601 Manual page 7

Microcontrollers

Advertisement

As discussed before, if interrupts can occur after the instruction which modifies the port
data register, and in the interrupt service routines read-modify-write instructions are
executed which also access this port, it is additionally recommended to temporarily disable
interrupts.
The built-in bitfield function of some C compilers allows to modify up to 16 bits of a bit-
addressable word. When this function is used, care mut be taken when several pins in
different bytes of a port are initialized, since the compiler might generate consecutive
BFLDL/H instructions which access the same port, e.g.:
_bfld (P3, 0x240A, 0x240A);
_bfld (DP3, 0x240A, 0x240A);
This instruction sequence may result in the following assembler instruction sequence:
BFLDH P3,#24h,#24h
BFLDL P3,#0Ah,#0Ah
; CAUTION: P3.13 and P3.10 are still inputs when this instruction reads P3
; ==> P3.13 and P3.10 values read from pin, maybe undefined
; ==> P3.13 and P3.10 SFR values may be overwritten with pin values
; ==> no WR# strobe or shift clock may be output
BFLDH DP3,#24h,#24h
BFLDL DP3,#0Ah,#0Ah
Therefore, this bitfield function should not be used
-
in particular when Port 3 pins are initialized
-
on 8xC166 microcontrollers for Port 1 and Port 0 pins, since these ports are
implemented as 16-bit wide ports, while on other C166 microcontrollers, these ports
are implemented as two 8-bit wide ports each, like most other I/O ports
For ports with bit protection (Port 2, 7, 8), these types of problems will not occur.
Semiconductor Group
Keil-Syntax: _bfld_ (...
; set P3.13/WR#/SCLK and P3.10/TxD0 to '1'
; set P3.1/T6OUT and P3.3/T3OUT to '1'
; switch P3.13 and P3.10 to output
; switch P3.1 and P3.3 to output
7 of 7
Port Initialization
and Direction Control
AP164601 1998-02

Advertisement

loading