Menu

Outputting to ports

Help
Homer79
2023-03-28
2023-03-28
  • Homer79

    Homer79 - 2023-03-28

    At the moment I am having to set all eight outputs individually,
    is there a way to output a byte variable to a port rather than setting
    each output. It basically a serial to parallel converter with a little bit
    of processing, but i need to avoid IO jitter.

    Define DS1 portb

    Do
      ' inputing serial data
      SetWith( DS1, a byte variable  )
    Loop
    END
    
     
    • jackjames

      jackjames - 2023-03-28

      To avoid IO jitter I program the whole port directly.
      I set the affected bits to their value in a variable, mask them with the bits that are not to be programmed, and then directly program the TRIS register with the value of the variable.
      (Example: TRISB = MyVar).

       
      • Anobium

        Anobium - 2023-03-28

        TRISB is chip specific - I recommend using portable port addresses like PORTB.

         
        • jackjames

          jackjames - 2023-03-28

          Certain. It was an example.

           
  • Anobium

    Anobium - 2023-03-28

    DS=255

    This will set all bits.

    Also, see #Option for jitter free option when setting bits.

     
  • Anobium

    Anobium - 2023-03-28

    Also, setting PORT.bit = 1 or 0 is faster. Where bit is a valid bit number.

    Then, see #option volatile

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.