CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

SPI problem with AD DAC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
denkov



Joined: 19 Dec 2005
Posts: 2

View user's profile Send private message ICQ Number

SPI problem with AD DAC
PostPosted: Thu Feb 02, 2006 2:31 pm     Reply with quote

Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Thu Feb 02, 2006 5:07 pm     Reply with quote

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   
}   
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group