Shop OBEX P1 Docs P2 Docs Learn Events
Using a MAX7219 with SHIFTOUT — Parallax Forums

Using a MAX7219 with SHIFTOUT

John CoutureJohn Couture Posts: 370
edited 2010-04-25 23:01 in General Discussion
Using a MAX7219 with SHIFTOUT
=============================

Definition:
A MAX7219 is a chip that enables you to control up to
eight 7 segement digits using just three pins on your
mcu.· (Datasheet attached).

Problem:
·· Just trying to setup a simple test where I control the
·· 7 seg digits on the Prof Dev Board using a MAX7219.
···(source code attached)
··
Setup:
·· SX28
·· Prof Dev Board (PDB)
·· MAX7219
··
Connections: (pin connections pg 1)
·· RB.0 is DQ·· (pin 01 on 7219)
·· RB.1 is LOAD (pin 12)
·· RB.2 is Clk· (pin 13)
··
·· 7 seg displays connected (seg A-G)
·· digit control connected (dig 0-4)··
·· power (19), ground (4,9)
·· pull-high resistor, 10k, (18)
·· DOUT (24) connected to an LED0 on PDB··
··
Experiment:
·· 1) Timing Diagram (pg 6) says to set LOAD to
····· LOW during data send and then toggle HIGH
····· once done sending 16 bits.
·····
·· 2) 7219 expects 16 bit packet (see pg 6),
····· the MSB 8 are control, LSB 8 are data.
·····
·· 3) Using SX/B command:
··
·· SHIFTOUT DQ,Clk,MSBFirst,$03· ' to indicate Digit 3
·· SHIFTOUT DQ,Clk,MSBFirst,$04· ' to display a 4
·····
Observation:
·· 1) I observed that LED0 briefly blinks each cycle
····· indicating that SOMETHING is coming OUT of the
····· 7219 implying that SOMETHING must be going
····· INTO the 7219 (I know, wishful thinking).
·····
Goal:
·· To write a program that will read the DS1307 on
·· the PDB and display the time on the 7 seg displays
·· also on the PDB.· SX/B has sample code for doing
·· something similar but it runs the LEDs directly
·· and uses many pins.· The MAX7219 will only use
·· three pins.··

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture

San Diego Miramar College

Comments

  • ZootZoot Posts: 2,227
    edited 2010-04-24 20:28
    John --

    This driver is blanked on startup. It has to be turned on. Then it never hurts to set PWM (0-31).

    Second, the latch/load line has to present a rising edge after data is shifted. It's like saying "do it". So after every 16 bits, if you want to see that info on the driver, you need to pulse the /CS-load pin. Not sure if you have the segs wired for automatic hex decode or raw control of the segments, so you may need to set the mode you want also. See the datasheet for register assignments.

    So presuming you have everything hooked up properly, you might want something like:

    LOAD PIN RB.1 OUTPUT ' make sure is output
    
    SHIFT_OUT SUB 1, 1
    BLIP_LOAD SUB 0, 0
    
    SHIFT_OUT $0C  ' writing to "shutdown" register
    SHIFT_OUT $01  ' turn driver on by writing 1 to LSB of shutdown register
    BLIP_LOAD  ' do those 16 bits
    
    SHIFT_OUT $0A  ' writing to "intensity" register
    SHIFT_OUT $18  ' 0-31 is brightness value; this is ~ 3/4 full brightness
    BLIP_LOAD  ' do those 16 bits
    
    SHIFT_OUT $01  ' writing to "digit 0" register
    SHIFT_OUT $0F  ' show this hex value if DECODE MODE IS CORRECT, otherwise control segments/dp
    BLIP_LOAD  ' do those 16 bits
    
    SHIFT_OUT $02  ' writing to "digit 1" register
    SHIFT_OUT $0F  ' show this hex value if DECODE MODE IS CORRECT, otherwise control segments/dp
    BLIP_LOAD  ' do those 16 bits
    
    ''''''''
    
    
    SUB SHIFT_OUT
       __PARAM5 = __PARAM1
       SHIFTOUT DQ, Clk, MSBFirst, __PARAM5  ' shift out a byte
       RETURN
    
    SUB BLIP_LOAD
       LOAD = 1
       PAUSEUS 10
       LOAD = 0
       RETURN
       
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • John CoutureJohn Couture Posts: 370
    edited 2010-04-25 19:52
    Thank you! That works! Thanks again!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • ZootZoot Posts: 2,227
    edited 2010-04-25 20:02
    Glad it worked.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • John CoutureJohn Couture Posts: 370
    edited 2010-04-25 23:01
    Just posted tutorial on how to do this. See:

    http://forums.parallax.com/forums/default.aspx?f=7&m=448191

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
Sign In or Register to comment.