Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Control a MAX7219 by Oshonsoft?

Status
Not open for further replies.
Hello Ian,

Yes I will use a matrix variant. 8x8. See comment in the upper comment lines in my code.
I will energize 60 leds at a simple way. With the use of the 7219 i cann use a small microcontroller.
At a later stadium 7 pcs. of 7-segment displays will be added. Thats the reason for the second 7219.

Reijnko
 
Hello Ian,

Yes I will use a matrix variant. 8x8. See comment in the upper comment lines in my code.
I will energize 60 leds at a simple way. With the use of the 7219 i cann use a small microcontroller.
At a later stadium 7 pcs. of 7-segment displays will be added. Thats the reason for the second 7219.

Reijnko

I understand the confusion. I've changed the scanlimit to 7 instead of 4.

Reijnko
 
Last edited:
Hi,

At this moment i am a little bit further.
For the test i have conected a 7-segment display instead of a led-matrix.
The only thing that is working now is the test mode. Other commands are not working. I've changed the program a little bit, including the initialisation. I've attached the new code and two images of the SPI communication. The signals are containing some noise.
Code:
'PIC 16F628A, with 16Mhz crystal and pull ups (10k) at SDI and CLK
'This program has to energize a 7-segment display at DIG0 at the MAX7219

Define CONF_WORD = 0x3f42

AllDigital
Define CLOCK_FREQUENCY = 16

Define SPI_CS_REG = PORTB  'with pull up (10k)
Define SPI_CS_BIT = 1
Define SPI_SCK_REG = PORTB  'with pull up (10k)
Define SPI_SCK_BIT = 2
Define SPI_SDI_REG = PORTB  'with pull up (10k)
Define SPI_SDI_BIT = 0
Define SPI_SDO_REG = PORTB  'not used
Define SPI_SDO_BIT = 3  'not used
SPIPrepare

Dim cnt As Byte

'****************************************
'Init MAX7219
SPICSOn
SPISend 0x0c  'Registeradress shutdown
SPISend 0x01  'value written To registry
SPICSOff
WaitMs 50

SPICSOn
SPISend 0x09  'Registeradress decode mode
SPISend 0xff  'value written to registry
SPICSOff
WaitMs 50

SPICSOn
SPISend 0x0b  'Registeradress scanlimit
SPISend 0x00  'value written to registry
SPICSOff
WaitMs 50

SPICSOn
SPISend 0x0a  'Registeradress intensity
SPISend 0x02  'value written to registry
SPICSOff
WaitMs 50

SPICSOn
SPISend 0x0f  'Registeradress testmode/ normal mode
SPISend 0x00  'value written to registry
SPICSOff
WaitMs 50
'End of init
'****************************************

main:
cnt = cnt + 1
If cnt > 15 Then cnt = 0  'counter for display test
WaitMs 500


'send to MAX8219
SPICSOn
SPISend 0x01  'Registeradress (DIG0)
SPISend cnt
SPICSOff

Goto main

'End of mainprogram
'****************************************

Here is an image of the CLK and SDI measurement:
20130712_112057.jpg

And here is an image of the CLK and LOAD measurement:
20130712_112004.jpg

After startup (power on) the display is showing a number or a wrong character (after each startup a different number or character).
Placing a capacitor near by the MAX7219 doesn't have any effect..

??
 
hi,

I have found in the past that 10K is too high a value, try 3k3.

E.
 
Hi E,

I've changed the resistors to 3k3, but it doesn't have any effect.
The strange thing is that when i turn displaytest to 1 at the init the display light up all the segments. That means to me that SPI is working correctly..
 
Hi E,

I've changed the resistors to 3k3, but it doesn't have any effect.
The strange thing is that when i turn displaytest to 1 at the init the display light up all the segments. That means to me that SPI is working correctly..

hi,
I have just run your program in Oshonsoft using a ext module for an SPI EEPROM, I can see all the program data bytes being load into the registers OK.

Have you double checked the initialise command codes for accuracy.

E
 
Hi E,

Thank you for testing. This morning i have studied the datasheet of the 7219. Ive tried different settings for the initialisation. Do i have to implement a pause after the prepare_spi command?
 
Hi E,

Thank you for testing. This morning i have studied the datasheet of the 7219. Ive tried different settings for the initialisation. Do i have to implement a pause after the prepare_spi command?

hi,
This is a demo program I use for a MCP3202 Dual A2D converter
I use a 20MHz xtal and the internal PLL
You can see I use minimal delays in the program
Eric

Code:
'18F2550 SPI dev1 17/10/10
Define CONFIG1L = 0x24
Define CONFIG1H = 0x0c
Define CONFIG2L = 0x38
Define CONFIG2H = 0x00
Define CONFIG3L = 0x00
Define CONFIG3H = 0x83
Define CONFIG4L = 0x80
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40

AllDigital

Define CLOCK_FREQUENCY = 20

Define SIMULATION_WAITMS_VALUE = 1

'''''''''''''''''''''''''''''''''''''''
Define SPI_CS_REG = PORTC
Define SPI_CS_BIT = 6

Define SPI_SDO_REG = PORTC
Define SPI_SDO_BIT = 7  ''5

Define SPI_SDI_REG = PORTB
Define SPI_SDI_BIT = 0

Define SPI_SCK_REG = PORTB
Define SPI_SCK_BIT = 1

''''''''''''''''''''''''''''''''''''''''
Define LCD_LINES = 2
Define LCD_CHARS = 16
''
Define LCD_BITS = 4  'allowed are 4 and 8 - number of data interface lines
Define LCD_DREG = PORTB
Define LCD_DBIT = 4  '0 or 4 for 4-bit interface, ignored for 8-bit interface

Define LCD_RSREG = PORTC
Define LCD_RSBIT = 0
Define LCD_EREG = PORTC
Define LCD_EBIT = 1
Define LCD_RWREG = PORTC
Define LCD_RWBIT = 2


Dim ch0lo As Byte
Dim ch0hi As Byte
Dim temp0 As Word

Dim ch1lo As Byte
Dim ch1hi As Byte
Dim temp1 As Word


ADCON0 = 0x03
ADCON1 = 0x0e

TRISA = 0
TRISB = 0
TRISC = 0

Lcdinit

SPIPrepare


Lcdcmdout LcdClear
Lcdout "Enable read MCP"

'MCP3202 control strings
'CmdStr0 = Trim("00000001 10000000 00000000") ' chn0
'CmdStr1 = Trim("00000001 11000000 00000000") ' chn1

loop:
PORTC.6 = 1

'channel0
SPICSOn
PORTC.6 = 0
SPISendBits 2, %11
SPIReceive ch0hi
SPIReceive ch0lo  'this will be discarded
PORTC.6 = 1

PORTC.6 = 0
SPISend 0x01
SPISend 0x80
SPIReceive ch0lo
PORTC.6 = 1
SPICSOff

'channel1
SPICSOn
PORTC.6 = 0
SPISendBits 3, %111
SPIReceive ch1hi
SPIReceive ch1lo  'this will be discarded
PORTC.6 = 1

PORTC.6 = 0
SPISend 0x01
SPISend 0xc0
SPIReceive ch1lo
PORTC.6 = 1
SPICSOff

ch0hi = ShiftRight(ch0hi, 1)
ch0hi = ch0hi And 0x0f
temp0 = (ch0hi * 256) + ch0lo  '0 thru 4095 counts

ch1hi = ShiftRight(ch1hi, 2)
ch1hi = ch1hi And 0x0f
temp1 = (ch1hi * 256) + ch1lo  '0 thru 4095 counts

Lcdcmdout LcdLine1Home
Lcdout #temp0, "   ", #ch0hi, "   ", #ch0lo, "   "
Lcdcmdout LcdLine2Home
Lcdout #temp1, "   ", #ch1hi, "   ", #ch1lo, "   "
WaitMs 200

Goto loop
 
Hi,

I've picked up the project again and i changed the MAX7219 for a MAX7221, which is fully SPI compatible .
It works fine now. I don't know why the MAX7219 doesn't work....

Thanks for all the reply's!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top