Shop OBEX P1 Docs P2 Docs Learn Events
Object for MAX7219 LED Display Drive — Parallax Forums

Object for MAX7219 LED Display Drive

SELSEL Posts: 80
edited 2015-02-15 16:28 in Propeller 1
I am a newbie to programming the propeller chip.
Has anyone created an object for the Max7219 LCD Driver?

Comments

  • LeonLeon Posts: 7,620
    edited 2010-02-08 21:29
    SPI should work. Code is available.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • SELSEL Posts: 80
    edited 2010-02-08 21:33
    Leon,

    Thank you! This my first time using the FORUM.

    So, if I understand you: I should look for an object that uses SPI for Max7219 interface?

    SEL
  • hover1hover1 Posts: 1,929
    edited 2010-02-08 23:53
    Here is an object that might get you started. It helped me getting started on this chip.

    Feel free to ask more questions.
  • SELSEL Posts: 80
    edited 2010-02-09 18:11
    Thank you so very much! I will study want I have downloaded.

    Stan Lindo
  • SELSEL Posts: 80
    edited 2010-02-09 18:59
    Hover1,

    I sent a reply, but did not use your signin name.

    Once, again thank you so very much for you assistance in helping me under stand how to use the MAX7219 chip in a spin object!

    I will take you up on your offer to allow follow up question.

    SEL (Stan Lindo)
  • MJBMJB Posts: 1,235
    edited 2015-02-15 11:54
    Hi there

    I reactivate this old thread, because I just got a module from ebay,
    And have some intermittend problems with my connecton to the prop.
    The display is running from 5V.
    The datasheet of the MAX7219 shows a
    Logic High Input Voltage VIH MINIMUM of 3.5 Volts.

    So do you drive this with pullup to 5V and DIRA instead of OUTA ??

    The SPI object I tried from Tachyon is just doing normal OUTA without pullup.
    Maybe this is the source of the strange behaviour.
    Thanks,
    Mrkus
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-02-15 12:05
    What kind of a display are you using?

    I have a driver for 8x8 arrays but when I recently purchased some 7-segment displays with MAX7219 chips, I used JonnyMac's driver in the OBEX.
  • MJBMJB Posts: 1,235
    edited 2015-02-15 13:24
    Duane Degn wrote: »
    What kind of a display are you using?

    I have a driver for 8x8 arrays but when I recently purchased some 7-segment displays with MAX7219 chips, I used JonnyMac's driver in the OBEX.

    Thanks, Duane,

    I am about to write a driver for TACHYON.

    My question is really primarily about the hardware specs.

    as the datasheet states:
    The datasheet of the MAX7219 shows a
    Logic High Input Voltage VIH MINIMUM of 3.5 Volts.
    so I was wondering if I need to drive this with
    DIRA
    instead of OUTA
    
    and use a pullup.

    I just simply tried with OUTA and 3.3V - so I was wondering if the problem could be caused by this.

    The display I have is a 8*7-segment LED.

    I can check JonnyMac's driver in the OBEX now to see if he uses DIRA or OUTA.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-02-15 13:45
    MJB wrote: »
    I can check JonnyMac's driver in the OBEX now to see if he uses DIRA or OUTA.

    Jon's driver actively drives the outputs (with outa). I have a lot of projects with MAX7219 chips and I always use the 3.3V logic from the Prop.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-02-15 14:18
    If in doubt allow for a Schottky diode in the supply of the MAX7219 as this will have the effect of lowering its Vih to around 3.1V.

    BTW, you could just use the SPIWR instruction to talk to this rather than a RUNMOD. Assuming P0 is the chip enable and you have used SPIPINS to set the pins.

    : LED! ( 8b addr -- ) 8 SHL OR
    : WRLED ( 16b -- ) SPIWR SPIWR 0 HIGH ;
  • MJBMJB Posts: 1,235
    edited 2015-02-15 15:09
    Duane Degn wrote: »
    Jon's driver actively drives the outputs (with outa). I have a lot of projects with MAX7219 chips and I always use the 3.3V logic from the Prop.
    Thanks Duane,
    good to know, that it 'should' work at 3.3V with OUTA
  • MJBMJB Posts: 1,235
    edited 2015-02-15 15:14
    If in doubt allow for a Schottky diode in the supply of the MAX7219 as this will have the effect of lowering its Vih to around 3.1V.
    thanks, I will try on
    [/QUOTE]
    BTW, you could just use the SPIWR instruction to talk to this rather than a RUNMOD. Assuming P0 is the chip enable and you have used SPIPINS to set the pins.

    : LED! ( 8b addr -- ) 8 SHL OR
    : WRLED ( 16b -- ) SPIWR SPIWR 0 HIGH ;[/QUOTE]
    yes, I used SPIWR like
    : 7219WR ( 8b addr -- ) 8 SHL OR #16 SHL 0 LOW SPIWR16 0 HIGH ;[/QUOTE]
    
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-02-15 15:45
    MJB wrote: »
    thanks, I will try on
    BTW, you could just use the SPIWR instruction to talk to this rather than a RUNMOD. Assuming P0 is the chip enable and you have used SPIPINS to set the pins.

    : LED! ( 8b addr -- ) 8 SHL OR
    : WRLED ( 16b -- ) SPIWR SPIWR 0 HIGH ;[/QUOTE]
    yes, I used SPIWR like
    : 7219WR ( 8b addr -- ) 8 SHL OR #16 SHL 0 LOW SPIWR16 0 HIGH ;
    

    Yes, that's right, but if you use SPIWR16 there is no need for the 16 bit left justification. If you setup your pins including the mask with SPIPINS it will automatically take CE low so you only need to take it high at the end of the transfer.

    6 bytes of code is all it takes to combine the address and data and clock it into the MAX7219.
    8 SHL OR SPIWR16 0 HIGH
  • MJBMJB Posts: 1,235
    edited 2015-02-15 16:06
    BTW, you could just use the SPIWR instruction to talk to this rather than a RUNMOD. Assuming P0 is the chip enable and you have used SPIPINS to set the pins.

    : LED! ( 8b addr -- ) 8 SHL OR
    : WRLED ( 16b -- ) SPIWR SPIWR 0 HIGH ;
    yes, I used SPIWR like
    : 7219WR ( 8b addr -- ) 8 SHL OR #16 SHL 0 LOW SPIWR16 0 HIGH ;
    
    Yes, that's right, but if you use SPIWR16 there is no need for the 16 bit left justification. If you setup your pins including the mask with SPIPINS it will automatically take CE low so you only need to take it high at the end of the transfer.

    6 bytes of code is all it takes to combine the address and data and clock it into the MAX7219.
    8 SHL OR SPIWR16 0 HIGH
    a more in depth study of the PASM reveals it ... thanks
    AND a DROP for the rest of the SPIWR16 needs to be added I think
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-02-15 16:28
    MJB wrote: »
    AND a DROP for the rest of the SPIWR16 needs to be added I think

    Yes, that's right as the data is rotated and left on the stack afterwards which is useful for fill loops or cascading operations.
    {HELP SPIWR ( data -- data2 ) 
    Simple fast, bare-bones SPI - transmits 8 bits MSB first - data must be left justified - data is not discarded but rotated by number of shift operations used
    Usage: $1234 SPIWR16 'transmit 16 bits
    SPIWR ( data -- data<<8 )	send the MSByte
    SPIWRB ( data -- data<<8 )   send the LSByte
    SPIWR16 ( data -- data<<16 )  send the LSWord
    SPIWRX permits variable number of bits if spicnt is set directly with @SPICNT COGREG! and those bits are shifted to MSBit before
    }
    SPIWR16			rol	tos,#24
     			mov	ACC,#8	' force a 16-bit transfer
    SPIWRB 			rol	tos,#24	' left justify and write byte to SPI (2.8us)
    SPIWR			add	ACC,#8	' code execution time of 2.25us + overhead
    SPIWRX			andn	outa,spice	' always activate the chip enable (saves time in HL)
    SPIwrlp			rol	tos,#1 wc	' assume msb first (140208 update now rotates)
    			muxc	OUTA,spiout	' send next bit of data out
    			xor	OUTA,spisck	' toggle clock
    			xor	OUTA,spisck	' toggle clock
    			djnz	ACC,#SPIwrlp
    			jmp	unext
    
Sign In or Register to comment.