PDA

View Full Version : getting my head around PICS with SR-Latch registers - and how to properly use them



dw_picbasic
- 29th January 2021, 19:40
Hello,
I am just starting to play with the 16F1825 PIC which has SR latch registers.
I understand the 16F1xxx family of PICs have the SR latch register - and previous PICs did not.
I understand this register facilitates better read-modify-write functionality.

But on the subject of sending commands to PORT registers, I've also read that the commands PORTC.4 = 0 and LATC.4 = 0 are essentially the same command - because the system ends up writing the same thing to the same PORT register.

With these PICs is there a "Best Practice" command - for turning on/off specific pins?

Thanks
dw

HenrikOlsson
- 29th January 2021, 22:20
In a perfect world (or a simulator) writing to PORT will have the same effect as writing to LAT. In the real world that's not always the case - depending on various circuimstances.
On any PIC that has LAT register I'd say best practise is to use the LAT register(s), they're there for a reason.

With that said, do note that having LAT register(s) and having a SR-latch peripheral is not at all the same thing.

dw_picbasic
- 29th January 2021, 22:39
Thanks Hendrick!

tumbleweed
- 30th January 2021, 00:24
With these PICs is there a "Best Practice" command
Yes. Write to the LAT register. Read from the PORT register.