Difference between using Port Output & OMR register?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
I am struggling to understand the difference between setting the ouput port using the Output or the OMR register. I realise that if you are using the output register this will require a read modify write sequence but sometimes this is useful.The reference manual seems to suggest this could effect other pins but surely not as long as the read is from the output resister itself and not the input register. The manual is not clear whether a read from the output register reads the register back i.e. what you are demanding or the true levels on the pins. I would expect the demanded levels to be read back as surely true levels could be obtained from the input register.Can anybody clarify this?
0 Likes
8 Replies
Not applicable
Hi Martoon,

Reading the Pn_OUT register will give you the status of what you demanding and not the actual level of the pin.
0 Likes
Not applicable
Hi Jackson,
Thanks that is what I thought. So why does the reference manual say you could effect other pins because of read modify write. If we read back demand use AND & OR appropriately and write back there is no possibility of effecting other pins as far as I can see. I presume using the OMR is probably more code efficient in a lot of cases?
0 Likes
User7804
Level 4
Level 4
Hi Martoon,

Just a guess: Maybe this is related to the PCx coding "3" meaning "Pn_OUTx continuously samples the input value". Could be useful for deep sleep mode, but I don't know the intention. And I'm not sure what the documentation wants to tell us exactly.

This statement is wrong, see below: OTOH I see no obvious problem with read-modify-write even it Pn_OUTx follows the input data.
0 Likes
Not applicable
Obetz - thanks for replying but I'm not sure what you are getting att with PCx coding.
However for your information it makes a big difference if Pn_OUT follows the input data because then if the port pin is driving, say, a capacitor or a device that pulls it down, say, a base of a transistor, then the port pin can be read back incorrectly and read modify write instructions on the whole port can have unexpected changes on other pins. If the read is the the actual Pn_OUT register itself then there is no danger of this effect and read modify writes are perfectly safe which was why I asked the question in the frist place!
0 Likes
User7804
Level 4
Level 4
Hi Martoon,

of course you are right with read back and read-modify-write, a well known issue. I shouldn't write postings while being in a hurry. Another example are open drain outputs.

Regarding "PCx coding", see the "Port Input/Output Control Registers" IOCRx with the PCx bit fields, described in Table 17-5 in the XMC1100 Reference Manual. Settings 3 (00011 binary) and 7 (00111 binary) are described "Pn_OUTx continuously samples the input value".

I didn't use this option so I can't say whether I understand correctly.
0 Likes
Not applicable
Cheers Obetz - I understand what you mean now but I must admit I don't really understand what 'continuously samples the input' means' because surely you can only sample it as often as your software polling. Any body out there understand what it means?
0 Likes
User7804
Level 4
Level 4
IIRC, in deep sleep the output register is read back instead of the input state.

In this case, it might be useful to have access to the last input state.

And seemingly, the output register is (ab-?) used for this.

IMO a bit weird, but I can imagine that one can construct a case where it is useful.

But as I wrote, that's just a wild guess and clearer docs would be nice.
0 Likes
Not applicable
HI all,

Just for clarified, the 'continuously samples' is only applicable when the pin is configured to input pin.
So there won't be any effect if it is configured as output pin.
0 Likes