Kenny
Joined: 07 Sep 2003 Posts: 173 Location: Australia
|
|
Posted: Thu Feb 02, 2006 5:07 pm |
|
|
The data sheet says that this dac can be used with spi.
From the timing diagrams, the clock needs a low to high transition at
mid-bit time, and the idle state of the clock is low.
Try a test routine like the one below
Connections:
Pic spi data out to dac data in
Pic spi clock to dac clock
Pic port pin to dac latch
Code: |
#include <18F452.h>
#use delay(clock=16000000)
#fuses HS,NOWDT,NOLVP,PUT,NOPROTECT,BROWNOUT
#define AD420_LATCH PIN_D1
int16 val = 0x7fff; // Half scale
void main(void)
{
setup_spi(spi_master | spi_l_to_h |spi_clk_div_16);
output_low(AD420_LATCH);
spi_write(val >> 8); // Send msb
spi_write(val & 0xff); // Send lsb
output_high(AD420_LATCH);
while(1); // Dac output should be half full scale
}
|
|
|