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

Can't initialize AD9852
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Frozen01



Joined: 23 Apr 2009
Posts: 32

View user's profile Send private message

PostPosted: Thu May 28, 2009 8:40 am     Reply with quote

I got some new parts today, and decided to replace the AD9852 with a new one. Works perfectly with out having to delay anything. Some how I think my first two AD9852 chips were bad because they never worked.

Here is my code.

Code:
#include <18F45J10.h>
#device ICD=TRUE
#device adc=8

#FUSES NOWDT, EC_IO, NODEBUG, NOXINST, STVREN
#FUSES NOPROTECT, FCMEN,IESO, PRIMARY

#use delay(clock=20000000)
#define UD_Clock         PIN_C2
#define IO_RESET         PIN_D4
#define DDS_MRESET         PIN_D5
#define DDS_CS            PIN_D6
#define DDS_CLK_EN          PIN_B2
#define DDS_SDI            PIN_C5
#define DDS_SDO            PIN_C4
#define DDS_SCK            PIN_C3

#include <stdio.h>

void main ()
   {
   #define SPI_MODE_0  (SPI_L_TO_H | SPI_XMIT_L_TO_H)
   #define SPI_MODE_1  (SPI_L_TO_H)
   #define SPI_MODE_2  (SPI_H_TO_L)
   #define SPI_MODE_3  (SPI_H_TO_L | SPI_XMIT_L_TO_H)
   int temp1, temp2, temp3, temp4;
   setup_spi(SPI_MASTER|SPI_MODE_0|SPI_CLK_DIV_16);
   output_high(DDS_CLK_EN);
   output_high(DDS_CS);
   delay_us(10);
   output_high(DDS_MRESET);
   delay_ms(1);
   output_low(DDS_MRESET);
   output_high(IO_RESET);
   delay_us(10);
   output_low(IO_RESET);
   output_low(DDS_CS);
   spi_write(0x07);
   spi_write(0x10);
   spi_write(0x64);
   spi_write(0x00);
   output_low(UD_CLOCK);
   spi_write(0x21);
   output_high(DDS_CS);
   output_high(UD_CLOCK);
   delay_us(1);
   output_low(UD_CLOCK);
   delay_us(10);
   output_high(IO_RESET);
   delay_us(10);
   output_low(IO_RESET);
   output_low(DDS_CS);
   spi_write(0x87);
   temp1=spi_read(0);
   temp2=spi_read(0);
   temp3=spi_read(0);
   temp4=spi_read(0);
   output_high(DDS_CS);
   delay_ms(500);
   while(1);
   }
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu May 28, 2009 9:24 am     Reply with quote

Quote:
Some how I think my first two AD9852 chips were bad because they never worked.

Yes, may be. Or some kind of hard to detect assembly error. You'll possibly never know!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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