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

how to create and use multiple I2c channels

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



Joined: 05 Jun 2006
Posts: 41
Location: Belgium

View user's profile Send private message Visit poster's website MSN Messenger

how to create and use multiple I2c channels
PostPosted: Mon Jun 05, 2006 2:35 pm     Reply with quote

i like to use 2 times TDA7318, b i cal set only 1 adress for it.
i was thinking to set up a second I2c channel.... but how??? and how should i use them?

plz advice
thanks,
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 3:03 pm     Reply with quote

One way to do it, is to create two separate driver files.
Each file has the same functions in it, but with "ch_0"
and "ch_1" added onto the end of each function name,
to designate that one driver is for the "channel 1"
TDA7318 chip, and the other driver is for the 2nd TDA7318
chip, which is on "channel 2".

In the program below, all of the code in the TDA7318_0.C file
will be compiled for i2c on pins B0 and B1. After that, a new
#use i2c statement is placed, which uses pins B2 and B3.
So all of the code in the 2nd driver file will be compiled to
use those pins.
Then notice in the main() program, each TDA7318 chip
has its own functions, which have either "ch_0" or "ch_1"
at the end of the function name. These functions are
in the TDA7318_0.C and TDA7318_1.C files. You have
to write these functions.
Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)

#use i2c(Master, SDA=PIN_B0, SCL=PIN_B1)
#include "TDA7318_0.C"

#use i2c(Master, SDA=PIN_B2, SCL=PIN_B3)
#include "TDA7318_1.C"

//============================   
void main()
{
init_TDA7318_ch_0();  // init channel 0
init_TDA7318_ch_1();  // init channel 1

set_TDA7318_volume_ch_0(0, 0);  // Set A, B volume on Ch. 0
set_TDA7318_volume_ch_1(0, 0);  // Set A, B Volume on Ch. 1


while(1)
}
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