SPI - The basics


Results 1 to 19 of 19

Threaded View

  1. #6
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    There are several ways to do it, but I would probably go for something like this;

    The upper 4-bits for DAC channel A, with 2x gain, with A active, will remain constant. So create a constant like ASel CON 4096. This would be the following in 16-bit binary: %0001000000000000.

    The lower 12-bits, with the 2 least significant bits ignored, + ASel would be your value to send to the DAC to adjust the channel A output.

    Just use a word variable. Load your word variable with any value from 0 to 1023, then shift this left x 2 so the 2 LSBs are 0, then add the ASel constant for the value to shiftout.

    Say your word var is ChanA, and it's = 501. ChanA = (ChanA << 2) + ASel.

    501d = %0000000111110101. Shifted left x 2 it's %0000011111010100. When you add the ASel constant, it ends up being %0001011111010100.
    Last edited by Bruce; - 1st September 2010 at 18:00.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Members who have read this thread : 1

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