Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

problem with i2c libary

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Tue Feb 28, 2012 8:37 pm    Post subject: problem with i2c libary Reply with quote

Hi friends,

now I was sitting half day to get i2c slave libary to run Sad((( I use 1281 as master (tried software i2c and hardware i2c) and attiny13 as slave device. Hardware is connected correct. 1281 can also read LM75 without any problems....

Here is my code for attiny13:

$regfile = "attiny13.dat"
$crystal = 9600000
'$baud = 57600

Config I2cslave = &H30
Config Adc = Single , Prescaler = Auto , Reference = Internal
Start Adc

Dim Choicer As Byte
Dim Wert_adc As Word
Dim Wert_byte As Word
Dim Wert_send As Byte

Do

If Choicer = 1 Then Wert_adc = Getadc(2)
If Choicer = 2 Then Wert_adc = Getadc(3)

Loop

I2c_master_needs_data:
_a1 = 100
Return


I2c_master_has_data:
Choicer = _a1
Return



master is:

$crystal = 16000000
$regfile = "M1281def.dat"
$baud = 4800
$hwstack = 600
$swstack = 600
$framesize = 600

$lib "i2c_twi.lbx"

Config Scl = Portd.0 ' we need to provide the SCL pin name
Config Sda = Portd.1 ' we need to provide the SDA pin name
Config Twi = 100000
I2cinit

do

I2cstart
I2cwbyte &H31
I2crbyte Test1 , Ack
I2cstop
waitms 20
loop


only "255" come back... so might be an error.... Have anybody an idea? I also tried software i2c on atmega1281... no luck Sad

Cheers
Back to top
View user's profile
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Tue Feb 28, 2012 9:06 pm    Post subject: Reply with quote

shit, bought wrong slave-cpu... should be tiny12 Sad
Back to top
View user's profile
MAK3

Bascom Member



Joined: 24 Sep 2010
Posts: 450
Location: Germany

germany.gif
PostPosted: Tue Feb 28, 2012 9:26 pm    Post subject: Reply with quote

Quote:
should be tiny12


http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&p=22764#22764


MAK3
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 932
Location: France

france.gif
PostPosted: Wed Feb 29, 2012 6:07 pm    Post subject: Reply with quote

hello,

I use attiny 45 for all small uses.
it is possible to use the registers as memory too but it is a big risk (see memory usage in the help)

for an I2C use, I think, you will need too much memory for the 12 or 13

bon courage
JP
Back to top
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum