Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
node said:I too will like help with this IC. I am a Bascom AVR user; I will like to know how to go about making a data table using Bascom AVR, to make my 7 segment Led light.
I have two seperate Led connected to the shift regiter connected to a AT90S2313, using a 10Mhz crystal.
This is how it is connected. I am using Common Cathode Leds and using NPN transistors.
http://home.wanadoo.nl/electro1/avr... are the transistors connection to the Leds http://www.blitzlogic.com/7seg_90.GIF
any help would be appreciated.
.equ LOW = r21
.equ HIGH = r22
.equ STCP = 2 ;storage clock
.equ SHCP = 3 ;shift clock
.equ DS = 4 ;data bit
Update_display_LOW:
ldi ZL,LOW (table*2)
ldi ZH,HIGH(table*2)
add ZL, LOW ;add offset to base
lpm ;read data to r0
mov r18,R0
rcall ShiftByte ;send byte to 74HC595
cbi PORTB, 1 ; turn on low display (ones)
ret
;----------------------------------------------------------
Update_display_HIGH:
ldi ZL,LOW (table*2)
ldi ZH,HIGH(table*2)
add ZL, HIGH ;add offset to base
lpm ;read data to r0
mov r18,R0
rcall ShiftByte ;send byte to 74HC595
cbi PORTB, 0 ; turn on high display (tens)
ret
;----------------------------------------------------------
Table:
.db 0b00111111,0b00000110,0b01011011,0b01001111
.db 0b01100110,0b01101101,0b01111100,0b00000111
.db 0b01111111,0b01100111
;----------------------------------------------------------
ShiftByte:
ldi r19, 8 ; 8 bits to shift
ShiftLoop:
sbrc r18, 0 ; skip if bit 0 = clr
sbi PORTB, DS ; else send a 1
sbrs r18, 0 ; send a 0
cbi PORTB, DS ;
sbi PORTB, SHCP ; pulse shift clock
lsr r18 ; next bit
cbi PORTB, SHCP ; end shift clock pulse
dec r19 ; one less bit
brne ShiftLoop ; loop for 8 bits
sbi PORTB, STCP ; pulse storage clock high
nop ;
cbi PORTB, STCP ; then return low
ret ;
;----------------------------------------------------------
rcall ShiftByte ;send byte to 74HC595
out PORTB,r18 ;of course you will have to change the other pins already using portb.
hi
here you go
here's a bit of code that will work with the 2313. The 2313 supports the lpm instruction so you don't have to store the table in eeprom. You can store the table in the flash and just use the lpm instruction to fetch the correct byte.
If your pinout is the same as the one here:
**broken link removed**
this will work for you (with some extra code for setting up ports, stack, etc.)
**SORRY, I don't do Bascom, asm only.***
Code:.equ LOW = r21 .equ HIGH = r22 .equ STCP = 2 ;storage clock .equ SHCP = 3 ;shift clock .equ DS = 4 ;data bit Update_display_LOW: ldi ZL,LOW (table*2) ldi ZH,HIGH(table*2) add ZL, LOW ;add offset to base lpm ;read data to r0 mov r18,R0 rcall ShiftByte ;send byte to 74HC595 cbi PORTB, 1 ; turn on low display (ones) ret ;---------------------------------------------------------- Update_display_HIGH: ldi ZL,LOW (table*2) ldi ZH,HIGH(table*2) add ZL, HIGH ;add offset to base lpm ;read data to r0 mov r18,R0 rcall ShiftByte ;send byte to 74HC595 cbi PORTB, 0 ; turn on high display (tens) ret ;---------------------------------------------------------- Table: .db 0b00111111,0b00000110,0b01011011,0b01001111 .db 0b01100110,0b01101101,0b01111100,0b00000111 .db 0b01111111,0b01100111 ;---------------------------------------------------------- ShiftByte: ldi r19, 8 ; 8 bits to shift ShiftLoop: sbrc r18, 0 ; skip if bit 0 = clr sbi PORTB, DS ; else send a 1 sbrs r18, 0 ; send a 0 cbi PORTB, DS ; sbi PORTB, SHCP ; pulse shift clock lsr r18 ; next bit cbi PORTB, SHCP ; end shift clock pulse dec r19 ; one less bit brne ShiftLoop ; loop for 8 bits sbi PORTB, STCP ; pulse storage clock high nop ; cbi PORTB, STCP ; then return low ret ; ;----------------------------------------------------------
If your pinout changes, you simply have to modify the table.
If you are not using a shift register, all you have to do is replace the lines:
with this:Code:rcall ShiftByte ;send byte to 74HC595
Code:out PORTB,r18 ;of course you will have to change the other pins already using portb.
It should work provided the pinout is the same as the one in shift register schematic (in the link above)
Good Luck