Ports interacting?? 16F1826


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: Ports interacting?? 16F1826

    Quote Originally Posted by mark_s View Post
    Keep in mind

    All of the new "Enhanced 12FXXXX and 16FXXXX" parts use the LATx register for changing the output state. Portx register for reading the input state.
    I would like to know more about "LATs". Know zero. Does PIC Basic Pro support these? Tell me more please! Sounds interesting!!

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Ports interacting?? 16F1826

    Quote Originally Posted by SOTASOTA View Post
    I would like to know more about "LATs". Know zero. Does PIC Basic Pro support these? Tell me more please! Sounds interesting!!
    Hi,

    Lat is short for latch. I not a good communicator, so I can't explain it better than the data sheet. The main thing to understand is that on the older pic16's we used portx.x to read or write to a pin. This could lead to R-M-W problem that Henrik pointed out. On the new pic16fxxxx,pic12fxxxx, pic18, dspic, and pic32 we use Latx.x to change the output. Portx.x is used to read a port pin. So on the above code you provided.
    Code:
    Low PORTA.1 
    Low PORTA.4 
    
    PORTA.1 = 1
    pause 1000
    PORTA.4 = 1
    pause 1000
    PORTA.4 = 0
    PORTA.1 = 1
    This is how it should be, as someone pointed out in the other thread.
    Code:
    Low LATA.1 
    Low LATA.4 
    
    LATA.1 = 1
    pause 1000
    LATA.4 = 1
    pause 1000
    LATA.4 = 0
    LATA.1 = 1
    Here a similar thread

    http://www.picbasic.co.uk/forum/showthread.php?t=15836

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Ports interacting?? 16F1826

    Hi,
    Just to clarify, writing to the PORT registers still works on ALL devices. The thing is that newer devices can run much faster (64MHz) compared to older (20MHz) so the risk of running into RMW issues are bigger.

    Using the LAT register (when available) for outputs is a good idea. However, I'm not entirely sure that using HIGH/LOW (or any high level pin/port command) on LAT works, actually I don't think it does, but I'd be happy to stand corrected on that.

    /Henrik.

Similar Threads

  1. 16F1826 cannot get MCLR to act as an INPUT
    By SOTASOTA in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 13th February 2014, 02:31
  2. Help to setup ADC for 16F1826
    By SOTASOTA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th February 2014, 00:06
  3. ADC problems with a 16F1826 chip
    By alec in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st September 2012, 22:09
  4. Using two AtoD channels - they're interacting?!
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th April 2010, 19:21
  5. LCD ports
    By electronicsuk in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th February 2004, 02:26

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts