Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Using multiple MAX 7219 8 Digit Displays

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Mon Jul 10, 2017 10:37 am    Post subject: Using multiple MAX 7219 8 Digit Displays Reply with quote

The max 7219 8 digit displays are very cheap to buy so I thought I would get some.
Then I looked for code to use them I found an example by Benoit to use one but not for multiple displays.
I developed code to use more than one it has six now but could be extended with ease.

NOTE when I went past two I started to get problems
I have found you MUST power each display separately do not daisy chain the power connections
power them from one central power feed.

Below is the code with dummy values loaded into the display buffer

There is more to come!

Regards Paul

Code:


  'multiple MAX 7219 8 DIGIT DISPLAY



$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 100
$swstack = 100
$framesize = 100
Config Portc.0 = Output                                     'PORT = OUTPUT
Config Portc.1 = Output                                     'PORT = OUTPUT
Config Portc.2 = Output                                     'PORT = OUTPUT


Declare Sub Displ_write(byval Pos As Byte , Byval Info As Byte , Byval Disnum As Byte)
Declare Sub No_op(byval T As Byte)
Declare Sub Max7219_setup
Declare Sub Buff_out(byval Disno As Byte)

' ---- USE PORT C
Cs_enable Alias Portc.2                                     ' chip-select 7219
Ser_clk Alias Portc.1                                       ' clk  7219
Ser_data Alias Portc.0                                      ' data  7219

Dim Seg_buff(6 , 9) As Byte                                 'enough for 6 x 7219s  9th byte for brightness

 '*** CONFIGURATION OF REGISTERS  7219
Call Max7219_setup






Seg_buff(1 , 8) = 14 + 128                                  'P.    ADD 128 TO TURN ON DECIMAL POINT
Seg_buff(1 , 7) = 13                                        'L
Seg_buff(1 , 6) = 11                                        'E
Seg_buff(1 , 5) = 12                                        'H
Seg_buff(1 , 4) = 10                                        '-
Seg_buff(1 , 3) = 3                                         '3
Seg_buff(1 , 2) = 2                                         '2
Seg_buff(1 , 1) = 1                                         '1

Call Buff_out(1)

Seg_buff(2 , 8) = 1                                         '1
Seg_buff(2 , 7) = 2                                         '2
Seg_buff(2 , 6) = 3                                         '3
Seg_buff(2 , 5) = 10                                        '-
Seg_buff(2 , 4) = 12                                        'H
Seg_buff(2 , 3) = 11                                        'E
Seg_buff(2 , 2) = 13                                        'L
Seg_buff(2 , 1) = 14                                        'P

Call Buff_out(2)

Seg_buff(3 , 8) = 1                                         '1
Seg_buff(3 , 7) = 2                                         '2
Seg_buff(3 , 6) = 3                                         '3
Seg_buff(3 , 5) = 4                                         '4
Seg_buff(3 , 4) = 5                                         '5
Seg_buff(3 , 3) = 6                                         '6
Seg_buff(3 , 2) = 7                                         '7
Seg_buff(3 , 1) = 8                                         '8

Call Buff_out(3)

Seg_buff(4 , 8) = 9                                         '9
Seg_buff(4 , 7) = 8                                         '8
Seg_buff(4 , 6) = 7                                         '7
Seg_buff(4 , 5) = 6                                         '6
Seg_buff(4 , 4) = 5                                         '5
Seg_buff(4 , 3) = 4                                         '4
Seg_buff(4 , 2) = 3                                         '3
Seg_buff(4 , 1) = 2                                         '2

Call Buff_out(4)



End









Sub Displ_write(byval Pos As Byte , Byval Info As Byte , Byval Disnum As Byte)
'Disable Interrupts
Reset Ser_data
Reset Ser_clk
Reset Cs_enable
   '===We need to send no operation to other 7219s
   '===so here we work out when to send
  Select Case Disnum

    Case 1                                                  'display 1
       Call No_op(5)
       Shiftout Ser_data , Ser_clk , Pos , 1 , 8 , 10
       Shiftout Ser_data , Ser_clk , Info , 1 , 8 , 10

    Case 2                                                  'display 2
       Call No_op(4)
       Shiftout Ser_data , Ser_clk , Pos , 1 , 8 , 10
       Shiftout Ser_data , Ser_clk , Info , 1 , 8 , 10
       Call No_op(1)

    Case 3                                                  'display 3
       Call No_op(3)
       Shiftout Ser_data , Ser_clk , Pos , 1 , 8 , 10
       Shiftout Ser_data , Ser_clk , Info , 1 , 8 , 10
       Call No_op(2)

    Case 4                                                  'display 4
       Call No_op(2)
       Shiftout Ser_data , Ser_clk , Pos , 1 , 8 , 10
       Shiftout Ser_data , Ser_clk , Info , 1 , 8 , 10
       Call No_op(3)

    Case 5                                                  'display 5
       Call No_op(1)
       Shiftout Ser_data , Ser_clk , Pos , 1 , 8 , 10
       Shiftout Ser_data , Ser_clk , Info , 1 , 8 , 10
       Call No_op(4)

    Case 6                                                  'display 6

       Shiftout Ser_data , Ser_clk , Pos , 1 , 8 , 10
       Shiftout Ser_data , Ser_clk , Info , 1 , 8 , 10
       Call No_op(5)

  End Select

Set Cs_enable
'Enable Interrupts

End Sub

Sub No_op(byval T As Byte)
 Local C As Byte
 Local H As Word
 H = 0
 For C = 1 To T
  Shiftout Ser_data , Ser_clk , H , 1 , 16 , 10
 Next C


End Sub


Sub Buff_out(byval Disno As Byte)

For Digit8 = 1 To 8

Call Displ_write(digit8 , Seg_buff(disno , Digit8) , Disno)

Next
End Sub




'*** CONFIGURATION OF REGISTERS  7219

Sub Max7219_setup
   Local A As Byte
 For A = 1 To 6
Call Displ_write(12 , 0 , A)                                ' SHUTDOWN

Call Displ_write(9 , 255 , A)                               ' NO Decode "B" For 1st 7

Call Displ_write(10 , 1 , A)                                ' MAXIMUM BRIGHTNESS

Call Displ_write(11 , 7 , A)                                'DISPLAY 8 DIGITS

Call Displ_write(15 , 0 , A)                                ' TEST OFF

    'blank all display digits
For Digit8 = 1 To 8

Call Displ_write(digit8 , 15 , A)
Next


Call Displ_write(12 , 1 , A)                                ' TURN ON
Waitms 100
 Next

 End Sub
 


Last edited by Paulvk on Tue Jul 11, 2017 12:05 pm; edited 1 time in total
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5915
Location: Holland

blank.gif
PostPosted: Mon Jul 10, 2017 10:47 am    Post subject: Reply with quote

thanks for sharing Paul.
Simple to use Very Happy

_________________
Mark
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Mon Jul 10, 2017 11:32 am    Post subject: Reply with quote

Hello Mark
Yes I wanted it simple.
Note there are errors in the comments next to buffer load because of cut and paste I will fix. >Done
Next I will read the ADCs and put that on the displays.
As with everything I post if you think it worthy you can put it in the examples.
Regards Paul
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum