View previous topic :: View next topic |
Author |
Message |
cyril_fr
Joined: 25 Sep 2005 Posts: 1
|
pic spi and ad8400 |
Posted: Sun Sep 25, 2005 12:07 pm |
|
|
hi i need your help
I want to write a value from a pic to an AD8400 (digital potentiometer) via spi but that doesn't work i have the correct signals but the ad8400 doesn't work correctely
doc of the
AD8400
my code
Code: |
#use delay (clock = 4194304) //Using 4Mhz External clock
#fuses HS, NOWDT, NOPROTECT, NOLVP
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#define CS_SPI PIN_B2
void main ()
{
int8 Data0,Data1,Analog;
int16 Data;
setup_spi (SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_64);
output_high(CS_SPI);
analog= 0x00;
while(TRUE){
{
data=0;
data=data | analog;
data=data << 6;
data1=data & 0xff;//lsb
data0=(data >> 8) & 0xff;//msb
output_low(CS_SPI);
delay_us(100);
spi_write(Data0);
delay_us(150);
spi_write(Data1);
delay_us(150);
output_high(CS_SPI);
delay_ms(5000);
analog = analog + 0x10;
}
}
} |
thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 25, 2005 12:20 pm |
|
|
Why don't you use the CCS driver, AD8400.C ?
It's in this folder:
c:\Program Files\Picc\Drivers
If just have the demo compiler, then you won't have the drivers. In that
case, then use http://www.google.com to search for these keywords:
AD8400 CCS
Then you will find it. |
|
|
akworob Guest
|
|
Posted: Thu May 21, 2009 6:09 am |
|
|
Just remove line
This because device takes 10 last bits as value (not first 10bits!) |
|
|
|