Discussion in "Project Help" started by    msideal    Oct 16, 2014.
Thu Oct 16 2014, 02:24 pm
#1
Hi Friends,
How can i generate more i/o's by using Atmega16 or Atmega32.... I tried different things but they doesn't work. I shall be very glad if anyone could help me in solving this problem.
Thanks.
Sat Oct 18 2014, 12:48 am
#2
Can you explain more about your problem.

What I/O do you need and what have you tried so far ?
 msideal like this.
Sat Oct 18 2014, 01:17 pm
#3
Actually I want to take inputs from the Push buttons. I want to connect 8 pins of microcontroller from Push Buttons and then control 42 outputs from it. Problem is that i want to use atmega16 or atmega32 but i don't have more pins to connnect my outputs. What should i do???????
Mon Oct 20 2014, 12:55 am
#4
Is there anyone who could help me in solving this problem????
Mon Oct 20 2014, 04:49 pm
#5
Use a 8bit shift register with latch control (e.g. CD4094) it can give you as many ports as you want.
Tue Oct 21 2014, 10:17 pm
#6
There are several types of latching driver you could use,
or something like the 74154
Tue Oct 21 2014, 10:24 pm
#7
Hi Friends,
Basically I want to expand i/o ports by using atmega16 or atmega32 using I2C Protocol in AVR. So, I select the shift register which supports I2C Protocol. Therefore I choose PCF8574 (SHIFT REGISTER). I want to control 39 outputs by using this IC, and the output of shift register IC will be connected with leds.
Now problem is that I write a code and I wanted to turn on and turn off leds according to my will. But the problem is that what sort of address and data I send to the port SLA and SDA. It turn on all the leds..... not the one that I desired to open.
I am attaching proteus file and code on Assembly Language. This circuit is not complete. Since I will attach more Shift registers with it to get 39outputs.
Please help me out.
Thank you.......
Cheers.....

Tue Oct 21 2014, 10:26 pm
#8
Coding on Assembly Language is attached here

CODE:
.INCLUDE "M16DEF.INC"

LDI R21,HIGH (RAMEND)
OUT SPH,R21
LDI R21,LOW (RAMEND)
OUT SPL,R21

CALL I2C_INIT
CALL I2C_START
LDI R27, 0b00000000
CALL I2C_WRITE
LDI R27, 0b00000011
CALL I2C_WRITE
CALL I2C_STOP

HERE:
RJMP HERE


I2C_INIT:
LDI R21,0
OUT TWSR,R21
LDI R21,0x47
OUT TWBR,R21
LDI R21, (1<<TWEN)
OUT TWCR,R21
RET

I2C_START:
LDI R21, (1<<TWINT) | (1<<TWSTA) | (1<<TWEN)
OUT TWCR,R21

WAIT1:
IN R21,TWCR
SBRS R21,TWINT
RJMP WAIT1
RET

I2C_WRITE:
OUT TWDR,R27
LDI R21, (1<<TWINT) | (1<<TWEN)
OUT TWCR,R21

WAIT3:
IN R21,TWCR
SBRS R21,TWINT
RJMP WAIT3
RET

I2C_STOP:
LDI R21, (1<<TWINT) | (1<<TWSTO) | (1<<TWEN)
OUT TWCR,R21
RET


[ Edited Tue Oct 21 2014, 10:28 pm ]
Tue Oct 21 2014, 11:34 pm
#9
@ msideal
Microchip MCP23008 I2C 8-bit I/O expander ports can also be used
as a reference coding
http://www.ermicro.com/blog/?p=1163
PCF8574 is also a I2C expander and standard i2c library is available but you are using assembly and that is for c
http://davidegironi.blogspot.com/2013/03/pcf8574-gpio-expander-library-for-avr.html#.VEaey2f7j8Q
Sat Oct 25 2014, 12:42 am
#10
Hi Friends,
I changed my approach and now i'm using CD4094 to expand my I/O's. It's a shift register IC. Problem is that when i send data to the data pin it doesn't switch on those leds that i want.....
As per CD4094 i made strobe pin low before start sending data and then send data with the clock.
I'm attaching the Proteus diagram and Assembly language code.
Please help me out
Thanks

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

ArnoldDiant
Fri Apr 26 2024, 03:53 am
RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm
Charlestehed
Wed Apr 24 2024, 05:20 pm