Professional Documents
Culture Documents
tiny2313andtwi|AVRFreaks
Signup
Login
Whatareyouinterestedin?
EntireSite
Search
tiny2313andtwi
Log inor registerto post comments Go To Last Post
Author
15 posts / 0 new
Message
Posted by
#1
Fivestar widget
Total votes: 0
(http://community.atmel.com/users/geoil1879)
Tags:
Top
Posted by
#2
david.prentice(http://community.atmel.com/users/davidprentice)
david.prentice(http://community.atmel.com/users/davidprentice):
http://www.avrfreaks.net/forum/tiny2313andtwi
1/12
3/10/2016
tiny2313andtwi|AVRFreaks
Total votes: 0
The Tiny2313 does not have a TWI interface. You have to use the USI
(http://community.atmel.com/users/davidprentice)
interface. Look for Atmel app note for using the USI as an I2C Master.
Level: 10k+ Postman
Joined: Sat. Feb 12, 2005
You will have to translate it into Assembler yourself.
Posts: 25744 View
posts(http://community.atmel.com/user/3320/content)
Location: Wormshill, England
David.
Posted by
Top
#3
melexis(http://community.atmel.com/users/melexis8211): Fri.
melexis(http://community.atmel.com/users/melexis8211)
Mar 28, 2008 03:30 PM
Total votes: 0
Afaik no tiny has native I2C support. But to save code you should use
the USI in two wire mode (provides basic support like shift register,
(http://community.atmel.com/users/melexis8211)
overflow interrupts, start/stop condition detection...) as David already
Level: New Member
posted (see Atmel application note AVR310).
Joined: Sat. Mar 22, 2008
Posts: 3 View
posts(http://community.atmel.com/user/229682/content)
Do you only have to interface an E2PROM? If so you maybe should
think about using a SPI EEPROM.
Best regards,
Tom
Posted by
Top
#4
geoil(http://community.atmel.com/users/geoil1879)
28, 2008 05:42 PM
Total votes: 0
2/12
3/10/2016
tiny2313andtwi|AVRFreaks
i could choose than i could make the project with an atmega88. But i
(http://community.atmel.com/users/geoil1879)
Level: New Member
can not.
Joined: Sun. May 21, 2006
Posts: 10 View
posts(http://community.atmel.com/user/52600/content)
Location: Romania
Posted by
david.prentice(http://community.atmel.com/users/davidprentice)
Top
#5
david.prentice(http://community.atmel.com/users/davidprentice):
Fri. Mar 28, 2008 06:40 PM
Total votes: 0
; parameter: data
; destroys: counter1
; .define DDRC,PINC,PORTC SCL,SDA
;
;****************************
; i2c_init MUST call first
;****************************
i2c_init:
cbi
PORTC,SCL
cbi
PORTC,SDA
sbi
DDRC,SCL
;sink SCL
cbi
DDRC,SDA
;float SDA
ret
;/***************************
; I2C start pulse .cs if free
;/***************************
I2C_Start:
http://www.avrfreaks.net/forum/tiny2313andtwi
cbi
DDRC,SDA
;float SDA
cbi
DDRC,SCL
;float SCL
rcall I2C_delay
clc
sbis
PINC,SDA
;free ?
ret
;no
sbis
PINC,SCL
;free ?
ret
;no
sbi
DDRC,SDA
rcall I2C_delay
sbi
DDRC,SCL
;sink SDA
;sink SCL and hold bus
3/12
3/10/2016
tiny2313andtwi|AVRFreaks
sec
i2c_xit: ret
;ours now
;sink SDA
rcall I2C_delay
sbi
rcall I2C_delay
cbi
DDRC,SCL
;float SCL
cbi
DDRC,SDA
;float SDA
rcall I2C_delay
ret
DDRC,SCL
;sink SCL
;/*******************************
; write data 8 bits .cs if ACK
;/*******************************
i2c_write: pushdata
ldi
counter1,8
i2c_write1: cbiDDRC,SDA
;8 bit data
;float SDA
rol
data
brcs
i2c_write2
sbi
DDRC,SDA
;sink SDA
i2c_write2:
rcall I2C_delay
cbi
rcall I2C_delay
sbi
DDRC,SCL
dec
counter1
brne
i2c_write1
cbi
DDRC,SDA
;float SDA
cbi
DDRC,SCL
;float SCL
rcall I2C_delay
clc
sbis
sec
DDRC,SCL
;float SCL
;sink SCL
PINC,SDA
sbi
DDRC,SCL
;sink SCL
pop
data
ret
;/**************************************
; receive data from SDA line, always NAK
;/**************************************
i2c_read: push counter1
ldi
counter1,8
;8 bit data
DDRC,SCL
;float SCL
i2c_read1: nop
http://www.avrfreaks.net/forum/tiny2313andtwi
cbi
rcall I2C_delay
sec
sbis
clc
rcall I2C_delay
dec
PINC,SDA
rol
data
;rotate left
sbi
DDRC,SCL
;sink SCL
counter1
4/12
3/10/2016
tiny2313andtwi|AVRFreaks
brne
i2c_read1
cbi
DDRC,SDA
;NAK
cbi
DDRC,SCL
;float SCL
rcall I2C_delay
sbi
rcall I2C_delay
cbi
DDRC,SDA
pop
counter1
ret
DDRC,SCL
;sink SCL
;leave bus hi
;/***********************
; delay time destroy temp
;/***********************
I2C_delay: ldi temp,10
I2C_delay_1:
dec
temp
brne
I2C_delay_1
;2
ret
;4
;1
Top
Posted by
#6
theusch (http://community.atmel.com/users/theusch)
theusch (http://community.atmel.com/users/theusch): Fri. Mar
28, 2008 06:55 PM
Total votes: 0
Quote:
(http://community.atmel.com/users/theusch)
http://www.avrfreaks.net/forum/tiny2313andtwi
5/12
3/10/2016
tiny2313andtwi|AVRFreaks
Posted by
Top
#7
melexis(http://community.atmel.com/users/melexis8211): Fri.
melexis(http://community.atmel.com/users/melexis8211)
Mar 28, 2008 08:19 PM
Total votes: 0
look here:
http://avrasm.tripod.com/twi26....(http://avr
(http://community.atmel.com/users/melexis8211)
Level: New Member
asm.tripod.com/twi26.html)
Posted by
Top
#8
Total votes: 0
(http://community.atmel.com/users/geoil1879)
microcontroller software in assembler. Thanks a lot!
Level: New Member
Joined: Sun. May 21, 2006
Posts: 10 View
posts(http://community.atmel.com/user/52600/content)
Location: Romania
http://www.avrfreaks.net/forum/tiny2313andtwi
Top
6/12
3/10/2016
tiny2313andtwi|AVRFreaks
david.prentice(http://community.atmel.com/users/davidprentice)
(http://community.atmel.com/users/davidprentice)
#9
Total votes: 0
Write in C, so you understand your logic. Then edit the generated ASM code so that your teacher
thinks it is all your own work.
David.
Posted by
theusch (http://community.atmel.com/users/theusch)
Top
#10
Total votes: 0
Quote:
(http://community.atmel.com/users/theusch)
I don't know exactly what geoil wants us to do for him/her. The USI
app note reference wasn't good enough. Nor was the CV suggestion,
and already a CV user (not entirely unexpected given the Romania
location). You'd think a hungry student would be devouring Google hits
and Forum hits and User Projects hits, but apparently not enough time
between handwringing sessions.
http://www.avrfreaks.net/forum/tiny2313andtwi
7/12
3/10/2016
tiny2313andtwi|AVRFreaks
_i2c_init:
cbi __i2c_port,__scl_bit
cbi __i2c_port,__sda_bit
sbi __i2c_dir,__scl_bit
cbi __i2c_dir,__sda_bit
rjmp __i2c_delay2
_i2c_start:
cbi __i2c_dir,__sda_bit
cbi __i2c_dir,__scl_bit
clr r30
...
Top
Posted by
#11
david.prentice(http://community.atmel.com/users/davidprentice)
david.prentice(http://community.atmel.com/users/davidprentice):
Fri. Mar 28, 2008 09:15 PM
Total votes: 0
Lee,
(http://community.atmel.com/users/davidprentice)
http://www.avrfreaks.net/forum/tiny2313andtwi
8/12
3/10/2016
tiny2313andtwi|AVRFreaks
Whereas I can probably read and follow widely differing C code, ASM is a
very personal thing. If it is not laid out in my style I am completely
lost.
So in fact I did not just edit generated ASM in this case. I wanted to
see if I could make sense of some Thai code. Yes, it is possible but it
required far more rearrangement than starting with C generated code.
David.
Posted by
theusch (http://community.atmel.com/users/theusch)
Top
#12
Total votes: 0
the point I was trying to make is that if OP had a little more initiative,
(http://community.atmel.com/users/theusch)
Posted by
ka7ehk(http://community.atmel.com/users/ka7ehk)
Top
#13
Total votes: 0
Ahhh, this sounds like an "assignment" I would have given back "in the
(http://community.atmel.com/users/ka7ehk)
Level: 10k+ Postman
day".
Joined: Fri. Nov 22, 2002
Posts: 16272 View
Goal: learn how to use timing diagrams and generate code that will
posts(http://community.atmel.com/user/7050/content)
Location: Tangent, OR, USA
implement that diagram. TWI is somewhat challenging (more complex)
http://www.avrfreaks.net/forum/tiny2313andtwi
9/12
3/10/2016
tiny2313andtwi|AVRFreaks
Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA
https://sites.google.com/site/or...
Posted by
Top
#14
Total votes: 0
theusch wrote:
Quote:
(http://community.atmel.com/users/geoil1879)
10/12
3/10/2016
tiny2313andtwi|AVRFreaks
Top
Posted by
#15
theusch (http://community.atmel.com/users/theusch)
theusch (http://community.atmel.com/users/theusch): Fri. Mar
28, 2008 11:19 PM
Total votes: 0
Quote:
(http://community.atmel.com/users/theusch)
Top
Jump To
megaAVRandtinyAVR
http://www.avrfreaks.net/forum/tiny2313andtwi
11/12
3/10/2016
tiny2313andtwi|AVRFreaks
http://www.avrfreaks.net/forum/tiny2313andtwi
12/12