Facing Problem in generating more i/o's by using AVR
Sat Oct 25 2014, 12:44 am
Assembly Language Code:
.INCLUDE "M16DEF.INC"
LDI R20,HIGH (RAMEND)
OUT SPH,R20
LDI R20,LOW (RAMEND)
OUT SPL,R20;
LDI R16, 0XFF ;
OUT DDRC, R16 ; TO SET PROTC AS OUTPUT
CBI PORTC, 0 ; TO CLEAR STB PIN WHICH IS CONNECTED TO PROTC.0
LDI R17, 0x81 ; OUR DATA
CLC ; TO CLEAR CARRY REGISTER
LDI R18,8 ; WE HAVE TO RUN LOOP FOR 8 CYCLES THAT IS Y WE HAVE KEPT 8
AGAIN:
ROL R17 ; FOR ROTATING OUR DATA
BRCS ONE ; OF CARRY IS HIGH THEN GO TO ONE
CBI PINC,1 ; OF CARRY IS 0 THEN SET DATA PIN TO 0 MANUALLY
JMP NEXT ;
ONE:
SBI pinc,1 ;
NEXT:
SBI PINC,2 ;
CALL DELAY ;
CBI PINC,2 ;
CALL DELAY ;
DEC R18 ;
BRNE AGAIN ;
SBI PINC,0 ;IN THE END WE HAVE TO SET HIGH THE STROBE PIN
HERE:
JMP HERE ;
DELAY:
LDI R22, 29 ;
LOOP:
NOP ;
DEC R22 ;
BRNE LOOP ;
RET
.INCLUDE "M16DEF.INC"
LDI R20,HIGH (RAMEND)
OUT SPH,R20
LDI R20,LOW (RAMEND)
OUT SPL,R20;
LDI R16, 0XFF ;
OUT DDRC, R16 ; TO SET PROTC AS OUTPUT
CBI PORTC, 0 ; TO CLEAR STB PIN WHICH IS CONNECTED TO PROTC.0
LDI R17, 0x81 ; OUR DATA
CLC ; TO CLEAR CARRY REGISTER
LDI R18,8 ; WE HAVE TO RUN LOOP FOR 8 CYCLES THAT IS Y WE HAVE KEPT 8
AGAIN:
ROL R17 ; FOR ROTATING OUR DATA
BRCS ONE ; OF CARRY IS HIGH THEN GO TO ONE
CBI PINC,1 ; OF CARRY IS 0 THEN SET DATA PIN TO 0 MANUALLY
JMP NEXT ;
ONE:
SBI pinc,1 ;
NEXT:
SBI PINC,2 ;
CALL DELAY ;
CBI PINC,2 ;
CALL DELAY ;
DEC R18 ;
BRNE AGAIN ;
SBI PINC,0 ;IN THE END WE HAVE TO SET HIGH THE STROBE PIN
HERE:
JMP HERE ;
DELAY:
LDI R22, 29 ;
LOOP:
NOP ;
DEC R22 ;
BRNE LOOP ;
RET
Sun Oct 26 2014, 06:08 pm
Hi Friends,
I made the strobe pin high before sending the data. After that the leds i want to open, they didn't hold. I am using Proteus to simulate it. As i start the simulation, the leds start on one by one, but that led which i want to hold it, that couldn't hold and it goes off....
Proteus diagram is attached....
Please help me out.
Thanks
Cheers...
I made the strobe pin high before sending the data. After that the leds i want to open, they didn't hold. I am using Proteus to simulate it. As i start the simulation, the leds start on one by one, but that led which i want to hold it, that couldn't hold and it goes off....
Proteus diagram is attached....
Please help me out.
Thanks
Cheers...
[ Edited Sun Oct 26 2014, 06:11 pm ]
Sun Oct 26 2014, 06:08 pm
Assembly Language code is here:::::.......... I made strobe high before sending the data
.INCLUDE "M16DEF.INC"
LDI R20,HIGH (RAMEND)
OUT SPH,R20
LDI R20,LOW (RAMEND)
OUT SPL,R20;
LDI R16, 0XFF ;
OUT DDRC, R16 ; TO SET PROTC AS OUTPUT
SBI PORTC, 0 ; TO CLEAR STB PIN WHICH IS CONNECTED TO PROTC.0
LDI R17, 0x81 ; OUR DATA
START:
CLC ; TO CLEAR CARRY REGISTER
LDI R18,8 ; WE HAVE TO RUN LOOP FOR 8 CYCLES THAT IS Y WE HAVE KEPT 8
AGAIN:
ROL R17 ; FOR ROTATING OUR DATA
BRCS ONE ; OF CARRY IS HIGH THEN GO TO ONE
CBI PINC,1 ; OF CARRY IS 0 THEN SET DATA PIN TO 0 MANUALLY
JMP NEXT ;
ONE:
SBI pinc,1 ;
NEXT:
SBI PINC,2 ;
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY ;
CBI PINC,2
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY ;
CALL DELAY ;
DEC R18 ;
BRNE AGAIN ;
CBI PINC,0 ;IN THE END WE HAVE TO SET HIGH THE STROBE PIN
JMP START ;
DELAY:
LDI R22, 29 ;
LOOP:
NOP ;
DEC R22 ;
BRNE LOOP ;
RET
.INCLUDE "M16DEF.INC"
LDI R20,HIGH (RAMEND)
OUT SPH,R20
LDI R20,LOW (RAMEND)
OUT SPL,R20;
LDI R16, 0XFF ;
OUT DDRC, R16 ; TO SET PROTC AS OUTPUT
SBI PORTC, 0 ; TO CLEAR STB PIN WHICH IS CONNECTED TO PROTC.0
LDI R17, 0x81 ; OUR DATA
START:
CLC ; TO CLEAR CARRY REGISTER
LDI R18,8 ; WE HAVE TO RUN LOOP FOR 8 CYCLES THAT IS Y WE HAVE KEPT 8
AGAIN:
ROL R17 ; FOR ROTATING OUR DATA
BRCS ONE ; OF CARRY IS HIGH THEN GO TO ONE
CBI PINC,1 ; OF CARRY IS 0 THEN SET DATA PIN TO 0 MANUALLY
JMP NEXT ;
ONE:
SBI pinc,1 ;
NEXT:
SBI PINC,2 ;
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY ;
CBI PINC,2
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY ;
CALL DELAY ;
DEC R18 ;
BRNE AGAIN ;
CBI PINC,0 ;IN THE END WE HAVE TO SET HIGH THE STROBE PIN
JMP START ;
DELAY:
LDI R22, 29 ;
LOOP:
NOP ;
DEC R22 ;
BRNE LOOP ;
RET
Mon Oct 27 2014, 12:15 am
Proteus file is heremsideal
Convert your Proteus file(s) to a Zip file before attaching.
Include the .hex file as well, so we don't need to
assemble/compile your code.
[ Edited Mon Oct 27 2014, 12:19 am ]
Mon Oct 27 2014, 12:46 am
sorry guys, i can't able to put the proteus file
The zip file is attached here
In this both circuit diagram and hex are attached
The zip file is attached here
In this both circuit diagram and hex are attached
Mon Oct 27 2014, 03:54 am
sorry guys, i can't able to put the proteus filemsideal
Only a certain file types can be attached.
"Allowed file types: | .zip | .gz | .jpg | .png | .gif | .rar | .pdf |"
The hex file you uploaded does not seem to be for the code in
your post 14.
For a test, what do you want to happen ?
Mon Oct 27 2014, 11:15 pm
i want to extend my i/o's by writing this code. i have to attach five CD4094 to get 40 outputs. At the moment i'm using only one CD4094 to check how it works...... but problem is... the leds that i want to be open. They don't on and other leds on... what's the problem??? I also made the hardware and check on it as well. but problem remains same
Tue Oct 28 2014, 03:59 am
Your error seems to be the use of PINC, which is for
reading input, not setting output.
This code should be a good starting point.
I posted the wrong one earlier.
It writes the data in variable "pattern" to the 8 LEDs, then stops.
reading input, not setting output.
This code should be a good starting point.
I posted the wrong one earlier.
It writes the data in variable "pattern" to the 8 LEDs, then stops.
[ Edited Tue Oct 28 2014, 04:46 am ]
Powered by e107 Forum System