Download Print this page

Siemens AP164601 Manual page 6

Microcontrollers

Advertisement

However, the following sequence is not recommended:
BSET P3.13
; set P3.13/WR#/SCLK to '1'
BSET DP3.13
; set direction of P3.13 to output
BSET P3.10
; set P3.10/TxD0 to '1'
; CAUTION: P3.13 is not yet switched to output when this instruction reads P3
;
(pipeline effect)
; ==> P3.13 value read from pin, maybe undefined
; ==> P3.13 SFR value may be overwritten with pin value by this instruction
; ==> no WR# strobe or shift clock may be output
BSET DP3.10
; set direction of P3.10 to output
...
Therefore, when several pins are to be initialized with single bit instructions on the same
port (and this port does not have bit protection), it is important that an instruction which
does not access this port is placed between two BSET Px / BSET DPx instruction pairs,
and in general after each instruction which has modified the port direction, as follows:
BSET P3.13
; set P3.13/WR#/SCLK to '1'
BSET DP3.13
; set direction of P3.13 to output
NOP
; or other instruction which does not access P3
BSET P3.10
; set P3.10/TxD0 to '1'
BSET DP3.10
; set direction of P3.10 to output
NOP
; or other instruction which does not access P3
Or, on C level:
_pubit (P3,13);
_pubit (DP3,13);
_nop();
_pubit (P3,10);
_pubit (DP3,10);
_nop();
When several pins in different bytes of a port (without bit protection) are to be initialized
with Bit Field instructions, also care must be taken that subsequent instructions will read
the correct port status, e.g.
BFLDH P3,#24h,#24h
BFLDH DP3,#24h,#24h
NOP
BFLDL P3,#0Ah,#0Ah
BFLDL DP3,#0Ah,#0Ah
NOP
Semiconductor Group
; set P3.13/WR#/SCLK and P3.10/TxD0 to '1'
; switch P3.13 and P3.10 to output
; or other instruction which does not access P3
; set P3.1/T6OUT and P3.3/T3OUT to '1'
; switch P3.1 and P3.3 to output
; or other instruction which does not access P3
6 of 7
Port Initialization
and Direction Control
AP164601 1998-02

Advertisement

loading