How do you read multiple GPIO bits into a single variable?

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Submitted by Joe on Thu, 02/21/2013 - 08:09 

 

We are planning on using a 16 bit external A to D converter with the 28335.
The A/D converter is a parallel interface. Is there a tutorial or example in VisSim Embedded, that shows how to read 16 individual bits and then combine them into a single variable?

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by Anders89 on Thu, 02/21/2013 - 08:22.

    Use an Embedded > Delfino > Digital/Analog Input block, and right click to configure. If they are contiguous bits, you select the start bit and number of bits. The configuration below is for 16 bits in port A starting as bit 10:

     

    DigitialIn-16Bit.png

     

    The resulting diagram looks like this:
     

    DigitialIn-16Bit-block.png

     

    If your bits aren't all contiguous, then you can combine smaller bit segments using shift and or blocks.