S12XS: Data Register vs Input Register

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S12XS: Data Register vs Input Register

1,320 次查看
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 回复

458 次查看
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 项奖励