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

Useful mcp41010 and ad8400 driver for beginners

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



Joined: 26 Jan 2006
Posts: 1

View user's profile Send private message

Useful mcp41010 and ad8400 driver for beginners
PostPosted: Fri Jan 19, 2007 8:57 am     Reply with quote

This driver is new version of mcp41010.c

Code:
#define CS PIN_B4      
#define SCLK PIN_B5      
#define SI PIN_B6      
                                           
void set_pot (int data) {   
   BYTE i;
   BYTE cmd[2];

   cmd[0] = data;
   cmd[1] = 0x11;
   
   setup_pot();

   output_high(CS);
   output_low(SCLK);
   delay_ms(1);
   output_low(CS);
   output_low(SCLK);
   delay_ms(1);
   for(i=1;i<=16;++i) {
      output_bit(SI, shift_left(cmd,2,0));

      output_high(SCLK);
      delay_us(2);
      output_low(SCLK);
   }
   output_high(CS);
   output_low(SI);
   output_low(SCLK);
}

void shutdown_pot () {      
   BYTE i;
   BYTE cmd[2];

   cmd[0] = 0;
   cmd[1] = 0x21;

   output_low(SCLK);
   output_low(CS);

   for(i=1;i<=16;++i) {
      output_bit(SI, shift_left(cmd,2,0));

      output_high(SCLK);
      output_low(SCLK);
   }
   output_high(CS);
}

void setup_pot() {      
                  
   delay_ms(1);
   output_low(CS);
   delay_cycles(1);
   output_high(CS);
   delay_cycles(1);

}
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