Menu

Compose or fashion a port

Help
EA7-JFV
2024-09-21
2024-09-23
  • EA7-JFV

    EA7-JFV - 2024-09-21

    Hello,

    Itś possible to compose a eight bit port (Imaginary name port) from different pin ports?

    Like this:

    Port "ACME" = PortB.0, PortB.1, PortC.3, PortD.5, PortD.8, PortB.3, PortC.1, PortD.2

    Then, by example, PortACME.6 = PortB.1, or PortACME.4 = PortD.5...

    Then, if I put

    PortACME = 0b'00101100, "it automatically" writes 0's in PortB.0, PortB.1, PortD.5, PortB.3 and PortC.1 and 1's in PortC.3, PortD.8 and PortB.3?

    Thanks

     
  • Anobium

    Anobium - 2024-09-22

    Is the same question as a previous post ? :-)

    You have two options - create a mask for each port used within the ACME variable, or, write a sub to set.

    The first method is efficient and the second method is very inefficient.

    You may do better with an external post expander and wire that up.

    Evan

    **Mask **

        #DEFINE PORTBMASK 0x11000000
        // PortB.0 = Acme.7
        // PortB.1 = Acme.6
        PortB = ( PortB and PORTBMASK ) or ( Acme and NOT PORTBMASK )
    
        .. same for all the other ports - create a mask and set. 
    

    BitSet

    Sub SetAcmeVar1
        // This is VERY VERY inefficient
        PortB.0 = Acme.7
        PortB.1 = Acme.6
        PortC.3 = Acme.5
        PortD.5 = Acme.4
        PortD.7 = Acme.3
        PortC.1 = Acme.1
        PortD.2 = Acme.0
    End Sub
    
     
  • EA7-JFV

    EA7-JFV - 2024-09-22

    It's alike a previous question, yes, but in this case I need a byte from more than two ports...

    I had been thinking for that in #define... but I had used it always for pins alias, not for masks...

    Thanks by your response, I see your code very utility

    Where can i find more uses of #define? In chm file it's... light, superficial

     
  • Anobium

    Anobium - 2024-09-23

    Great point re Help.

    Help me update the Help page. Ask any questions so I can improve.

    Evan

     

    Last edit: Anobium 2024-09-23
    • EA7-JFV

      EA7-JFV - 2024-09-23

      Oh! It has a great honour for me if I'm capable to achieve help this project.

      Thanks,

       
      • Anobium

        Anobium - 2024-09-23

        Yes, please help us help others in the future.

         
        👍
        1
  • Anobium

    Anobium - 2024-09-23

    Here is the master Help file. https://github.com/GreatCowBASIC/Help/blob/main/source/define.adoc

    Use this has the master file for your comments.

    This master file will be used to create the Help once we have finalised any more changes.

     

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.