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 support@ccsinfo.com

AD7691 Driver

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
gianni_pancrazi



Joined: 13 Feb 2007
Posts: 4

View user's profile Send private message

AD7691 Driver
PostPosted: Wed Feb 21, 2007 10:40 am     Reply with quote

At the end I managed to realize it... Very Happy
I'm using a 4 wire bus, with CS.

Code:

#include<Header.h>
#device *=16
#use delay(clock=16000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#define SDI    PIN_B4
#define SDO  PIN_C5      // the pin description is PIC oriented
#define SCKL PIN_C3
#define CNV  PIN_A4
#define LED  PIN_B2
int32 data=0;

int i;

void main()
{
unsigned long cnt=0;

while(1)
{
   output_high(SDO);                  
    output_high(CNV);         /* Starting conversion */
   output_low(SDO);                  
    delay_us(15);
                        /* Conversion Ended */

   for(i=19;i>0;--i)
//   for(i=32;i>13;--i)
               {   
               output_low(SCKL);
               output_high(SCKL);
               shift_left(&data,3,input(SDI));  /* maybe 1 instead of 3???*/
            //   bit_set(data, i)
            //   this function is too slow to be used in the application...
               }

   output_high(SDO);                  
   output_low(CNV);

   cnt ++;
   if (cnt==10000)
   {   
//      printf("\r the acquired value is: %x", data);
      printf("%x", data);
      data=0;
      output_toggle(LED);      /* Blinking LED for debugging*/
      cnt=0;
   }



} ;      



} // main() END


I will happy if anybody of u has comments/suggestions...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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