View previous topic :: View next topic |
Author |
Message |
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Jul 14, 2020 6:37 am Post subject: |
|
|
Some of what I did with 7 segment display
I created an array in eeprom with the digit values.
This let me simply reference the binary display value
I also used serial to parallel 74HC595 drivers
this reduced the number of cpu ports
Below is some code to try to explain what I did
Note I am trying to find a clock I did with four 7 segment displays
You can also see in application note AN #196 me using eeprom this way
Regards Paul
Code: |
' so instead of this
Data &B0110_1111 '0
Data &B0000_0110 '1
Data &B1010_1011 '2
Data &B1000_1111 '3
Data &B1100_0110 '4
Data &B1100_1101 '5
Data &B1110_1101 '6
Data &B0000_0111 '7
Data &B1110_1111 '8
Data &B1100_1111
'I did this
'Below $eeprom will store the values in eeprom saving flash space
'If they are the first to store in eeprom then
dim segs(10) as eram byte
'this will refer to the first 10 locations in eeram as the DIM statements
'allocate them in order
'so another
dim cats(10) as eram byte
'refers to bytes 11 onwards and so on
'so now to get the byte for the number 3 all I need to do is
'use segs(3)
$eeprom
Data &B0000_0110 '1 segs(1)
Data &B1010_1011 '2
Data &B1000_1111 '3
Data &B1100_0110 '4
Data &B1100_1101 '5 segs(5)
Data &B1110_1101 '6
Data &B0000_0111 '7
Data &B1110_1111 '8
Data &B0110_1111 '9 segs(9)
Data &B1100_1111 '0 segs(10)
$data
'note check byte (data) values not tested
|
Last edited by Paulvk on Tue Jul 14, 2020 6:49 am; edited 1 time in total |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Tue Jul 14, 2020 6:48 am Post subject: |
|
|
EDC wrote: | For 7SEG LED displays multiplexing you should have 50Hz for each display so for four of them you should calc 4x50Hz=200Hz.
Now look for your speed -> 16MHz/256=62500Hz Now 16bit Timer1 65536-62500=3036. So 62500Hz/3036=20Hz ONLY
For 200Hz you should use Prescaler = 2 and Timer1 = 25536
Second thing. Instead this code:
Code: | Presenta:
Timer1 = 62500
If Cnt < 4 Then
Incr Cnt
Else
Cnt = 1
End If
If Cnt = 1 Then
Q1 = 0 : Q2 = 0 : Q3 = 0 : Q4 = 1
Portd = Lookup(w4 , Tabla)
End If
If Cnt = 2 Then
Q1 = 0 : Q2 = 0 : Q3 = 1 : Q4 = 0
Portd = Lookup(w3 , Tabla)
End If
If Cnt = 3 Then
Q1 = 0 : Q2 = 1 : Q3 = 0 : Q4 = 0
Portd = Lookup(w2 , Tabla)
End If
If Cnt = 4 Then
Q1 = 1 : Q2 = 0 : Q3 = 0 : Q4 = 0
Portd = Lookup(w1 , Tabla)
End If
Return
|
Use something like this:
Code: |
Presenta:
Timer1 = 25536 'remember Prescale = 2
Incr Cnt : If Cnt > 4 Then Cnt = 1
Select Case Cnt
Case 1
Q1 = 0
Portd = Lookup(w4 , Tabla)
Q4 = 1
Case 2
Q4 = 0
Portd = Lookup(w3 , Tabla)
Q3 = 1
Case 3
Q3 = 0
Portd = Lookup(w2 , Tabla)
Q2 = 1
Case 4
Q2 = 0
Portd = Lookup(w1 , Tabla)
Q1 = 1
End Select
Return |
|
I already tested them with your timer Timer1 = 25536 and I agree with your calculation but it is the same fault as before.
It already works just change but you are very strange because it worked?
Code: |
Timer1 = 25536
If Cnt < 4 Then
Cnt = Cnt + 1
Else
Cnt = 1
End If
|
These if the 4 digits work well.
Code: | Timer1 = 25536
If Cnt < 5 Then
Cnt = Cnt + 1
Else
Cnt = 1
End If
| |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Tue Jul 14, 2020 10:09 am Post subject: |
|
|
Why call [Presenta] in the main routine (Do-Loop) without enabling interrupts?
I think your fix just happens to be in sync and the display looks good.
Furthermore, when you look at the picture, it looks like there is a ghost in the next digit. |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
|
Back to top |
|
|
|