Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

I have a problem in creating a program with 2x7 segments in PIC18f4520...

Status
Not open for further replies.

mohideen

Member level 2
Joined
Jan 19, 2011
Messages
45
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,580
Hi all,
I am asked to use 2x7segments, to count from 00-60 than stop...
I do not know how to run two seven segments togather...
Someone pls help... Thx...
 

You should use multiplexing. Google for tutorials
 

Hi
or you can use it with controlling on the enable bit of the seven segment send like this
program seven_seg_counting
dim i as byte
dim j as byte
dim v as byte
dim por1 as byte
dim por2 as byte
' This function returns masks
' for common cathode 7-seg display
sub function mask(dim num as byte) as byte
select case num
case 0 result = $3F
case 1 result = $06
case 2 result = $5B
case 3 result = $4F
case 4 result = $66
case 5 result = $6D
case 6 result = $7D
case 7 result = $07
case 8 result = $7F
case 9 result = $6F
end select
end sub
sub procedure interrupt
if v = 0 then
PORTB = por2 ' Prepare mask for digit
PORTA = 1 ' Turn on 1st, turn off 2nd 7seg
v = 1
else
PORTB = por1 ' Prepare mask for digit
PORTA = 2 ' Turn on 2nd, turn off 1st 7seg
v = 0
end if
TMR0 = 0
INTCON = $20
end sub
main:
OPTION_REG = $80
por2 = $3F
j = 0
TMR0 = 0
INTCON = $A0 ' Disable PEIE, INTE, RBIE, T0IE
TRISA = 0
TRISB = 0
PORTB = 0
PORTA = 0
do
for i = 0 to 99 ' Count from 0 to 99
' Prepare ones digit
j = i mod 10
por1 = mask(j)
' Prepare tens digit
j = (i div 10) mod 10
por2 = mask(j)
Delay_ms(1000)
next i
loop until false
end.



this program was written in mikrobasic to count from 00 to 99
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top