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

Simple i2c programming issue

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



Joined: 19 Nov 2007
Posts: 9

View user's profile Send private message

Simple i2c programming issue
PostPosted: Thu Nov 29, 2007 9:59 am     Reply with quote

I'm really just looking for someone to help me out with this code, I know there has to be any easier way to configure all the registers in the AD7147 that I'm using, but I just don't know how to code it, here is what I have so far:

[/code]

#include <18F4520.h>
#include <AD7147RegMap.h>
#use i2c(Master, sda=PIN_C4, scl=PIN_C3)

void main()
{
i2c_start();
i2c_write(STAGE0_CONNECTION);
i2c_write(0xFFFE);
i2c_stop();

i2c_start();
i2c_write(STAGE0_CONNECTION+1);
i2c_write(0x1FFF);
i2c_stop();

i2c_start();
i2c_write(STAGE0_CONNECTION+2);
i2c_write(0x0000);
i2c_stop();

}

All I have to do is go through a list of registers and assign them values, I just don't know how to do it an easier way. Could someone please show me how to do this easier?
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Nov 29, 2007 10:13 am     Reply with quote

Some of the i2c devices I have worked with autoincrement the address between bytes. This allows you to write to consecutive bytes by just addressing the first byte and then writing multiple bytes.
_________________
The search for better is endless. Instead simply find very good and get the job done.
achotto



Joined: 19 Nov 2007
Posts: 9

View user's profile Send private message

PostPosted: Thu Nov 29, 2007 11:52 am     Reply with quote

"The AD7147-1 address pointer register automatically increments after each write. This allows the master to sequentially write to all registers on the AD7147-1 in the same write transaction"

This is a quote from the data sheet of the AD7147. So can you give me an example of how I would write to a set of sequential registers? would I just do a lot of i2c_write() commands in a row?
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