S12XS: Data Register vs Input Register

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S12XS: Data Register vs Input Register

1,435件の閲覧回数
JadhavAj
Contributor I
Hi,
 
We can read the pin state either from Port data register ( PTT, PTS,PTM,PTP,PTH,PTJ) or corresponding port input register ( PTIT, PTIS, PTIM, PTIP, PTIH, PTIJ).
 
Is reading from port input register prefferable than port data register, why?
 
Also for Ports A,B,C,D,E,K ( which are General purpose I/O registers) we need to read from port data register only.
 
So am I correct if I write to ports using data registers and read from port input registers?
 
 
Regards,
 Ajay
ラベル(1)
0 件の賞賛
返信
1 返信

573件の閲覧回数
Steve
NXP Employee
NXP Employee
The input register reflects the true value of the logical state on a port pin while the port register reflects the intended value on the port pin. The distinction applies to output pins; input pins will return the same value in both registers.
For output pins the port register contains the output value that you are trying to put on the pin while the input register reflects the actual value. A difference between these two indicates that something external to the MCU is overdriving the output port to a different state.
It's up to you how you use the registers. Assuming the outputs can never be overdriven or you are only using inputs then you can use the port register to read the state of the port. If you are concerned about the status of the output pins then use the input register to confirm the pin is in the state that you expect.
You must always write to the port register to set the intended state of the output pin.
0 件の賞賛
返信