How do I use GPIO to write to 12-bit DAC?

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

Submitted by Viswanathan on Mon, 06/29/2009 - 20:36 

I need to send out 2 different signals of 12 bits each. Just for testing I have connected both outs to the same signal for testing.
I dont know how to setup uni-polar or bi-polar.
My signal will be from say -3 to +3. I expect -3 to give 0x0000 and +3 to be 0xFFF

Tagged:

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited November 2020

     

    Submitted by pete on Mon, 06/29/2009 - 20:41.

    VisSim supports contiguous bit access on GPIO read or write, so just setup the digital out block to use the bits you want, and create a transform to map from +/-3 to 0 to 0xFFF. The key to the transform is to scale the +-3 input to 0-8 in a fx4.16 scaling, then using the VisSim fixed-point shift block to give a right adjusted 12-bit result. I have attached a simulation and an embedded diagram to illustrate this.

    Unable to find an attachment - read this blog