View previous topic :: View next topic |
Author |
Message |
small_chick
Joined: 17 Jul 2012 Posts: 53
|
LATx & PORTx registers in dsPIC30F4011 ??? |
Posted: Wed Oct 24, 2012 4:25 am |
|
|
Hi everybody ! I have got a trouble that is why we need LADx register while PORTx register is available ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9250 Location: Greensville,Ontario
|
|
Posted: Wed Oct 24, 2012 5:19 am |
|
|
The short answer...we don't 'need' both but it's a 'feature' on the newer PICs. It does allow the programmer some 'options' not available decades ago.
Really you should read the datasheet on the PIC, especially the chapter on the PORTS. Then, read the same information on say the PIC16C84.
Also study the diagrams as to the structure of the ports. PICs have evolved' over the past 3 decades !
I'll lay odds that 90% of the 'features' of a PIC are not used in 90% of the projects they are used in.
This isn't a CCS C question, more a PIC philosophy one. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19559
|
|
Posted: Wed Oct 24, 2012 7:07 am |
|
|
The key one is that it avoids the RMW problem, if you write to the latch, and read from the port. On the PIC16, this was unavoidable, without using a separate RAM register and always writing to this rather than the port.
Best Wishes |
|
|
small_chick
Joined: 17 Jul 2012 Posts: 53
|
|
Posted: Wed Oct 24, 2012 7:44 am |
|
|
thanks Ttelmah and Temtronic ! but could you explain more about RMW problem Ttelmah ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19559
|
|
Posted: Wed Oct 24, 2012 8:06 am |
|
|
Just do a search.
It has been covered many hundreds of times here, and on MicroChip's site, and even in a couple of application notes from them.
In fact the first google hit on "PIC RMW problem", links to a really good overview of this, and how the separate LAT access avoids this.
Best Wishes |
|
|
small_chick
Joined: 17 Jul 2012 Posts: 53
|
|
Posted: Wed Oct 24, 2012 9:26 am |
|
|
thanks for your advice, Ttelmah ! |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Thu Oct 25, 2012 1:58 am |
|
|
temtronic wrote: | The short answer...we don't 'need' both but it's a 'feature' on the newer PICs.It does allow the programmer some 'options' not available decades ago.... |
Funny thing to say. I would argue that LAT is a must have for any embedded application dealing with read/write I/O where a "port" has some pins configured as inputs and others as outputs. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
|