DAC LTC1257 and spi

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear friends,
I need to interface a LTC1257 which is a 12-bit DAC with a mega16. The linear technologies says that this DAC has a serial SPI interface.
I have found assembly code that bit-bangs the serial interface, but I want to use SPI and C.

I know that SPDR is 8-bit and for LTC1257 I need a 12-bit word. So I am going to need 2 data transfers.
Should I feed 4bit junk and then MSB to LSB bits in a total of 16-bit or should I send MSB to LSB bits and then 4-bit junk to complete the 2 data transfers?

Any help is welcomed!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which chip are you using? Does the LTC1257 complain if you sent it 16 bits? If it does then it's got to be bit banged.

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I use an atmega16.
How will I "hear" the complaint?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Usually by not working as expected :)

The DAC will store the 12 last bits it receives, so send 4 junk bits first then 12 bits of data, then take /LOAD low and that should do the trick.

So basically, 2 byte transfers and the DAC will ignore the first four bits.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you very much.

Quote:

the DAC will store the 12 last bits it receives

Does this behavior differs from chip to chip?

Also I believe the datasheet says /LOAD low leaves transparent the DAC register and when high the register is latched.

Thank you very much.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many SPI chips can be daisy chained and whatever data goes in comes out the other end to the next chip. You only need to make sure that the data required by a particular chip is in the correct spot in the sequence of bytes. When the LOAD or LATCH is asserted then whatever is present inside the chip is captured.

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I see. So 4 junk bits firstly then 12 bits of data in a total of 16 bits.
I will test it and tell you the results.
Thank you very much jayjay1974 and js.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looking at the data sheet, it looks as if you can shift in as many bits as you like. When the !LOAD is true, it will read the last 12 bits.

So you just send your data msb first via SPI and see. But since you have working bit-banged code, you only have to experiment with a different # of bits to verify the behaviour.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
But since you have working bit-banged code, you only have to experiment with a different # of bits to verify the behavior.

I don't have a PCB made yet, but I will use SPI to control a DAC and an ADC, so bit-banging is not a choice.
In the worst case scenario I will substitute the LTC1257 with an equivalent one with known SPI behavior.
Thanks for your answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you have an update? I have selected atmega8 and need to interface to the exact same LTC1257. Did you get SPI interface working to this DAC?

And just for yucks, anybody remember BASIC? I found this app note showing bit banging this DAC using a micromint chip:

http://www.micromint.com/app_not...

Regards,
Scott

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I remember BASIC but with a M8 and a REAL spi you don't need to bit bang anything.

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly