bluetooth
Joined: 08 Jan 2005 Posts: 74
|
|
Posted: Sat Mar 26, 2005 5:55 pm |
|
|
This chip is nice and simple, hardly needs a "driver".
All you need to do is:
Code: |
// SPI MODE 0,0 is set up earlier
DAC_CS = 0; // Drop chip select
spi_write(dac_ms_byte);
spi_write(dac_ls_byte);
DAC_CS = 1; // Raise chip select
|
dac_ms_byte holds bits 15-8, dac_ls_byte holds bits 7-0. From the data sheet, you can decide how to fill them in. Basically, there are four configuration bits and 12 data bits. You can select the DAC you want to write to, whether or not you use the Vref buffer, set the Vref gain (handy!), and to put it in shutdown mode. It's important to set the Output Power Control Bit (SHDN) bit or you won't see any output.
From the data sheet:
Quote: |
bit 15 A/B: DACA or DACB Select bit
1 = Write to DACB
0 = Write to DACA
bit 14 BUF: VREF Input Buffer Control bit
1 = Buffered
0 = Unbuffered
bit 13 GA: Output Gain Select bit
1 = 1x (VOUT = VREF * D/4096)
0 = 2x (VOUT = 2 * VREF * D/4096)
bit 12 SHDN: Output Power Down Control bit
1 = Output Power Down Control bit
0 = Output buffer disabled, Output is high impedance
bit 11-0 D11:D0: DAC Data bits
12 bit number �D� which sets the output value. Contains a value between 0 and 4095.
|
Have used this part - works well.
Hope this helps.... |
|