Jump to content

Can I treat a max7221 as DOUT with 2 SRs?


intellijel

Recommended Posts

I was looking at ways to hook up a max7221 to the midibox. I am always thinking in terms of retaining the functionality of a midbox64 but being able to change how certain things are done.

I know there was a max72xx driver created as part of the Stribe project in the repository However I am not sure how to hook this up to core if I am using it for DOUT, DIN and AIN modules as well.

I am also trying to avoid re-inventing the wheel or writing too much new code since the BLM project already exists and works well.

I was wondering if I could just connect a max7221 chip in place of where two 74HC595's on a DOUT module would be and then used the normal MIOS code for writing to a dout module to control it? (as long as I read the max7221 data sheet and sent the appropriate values to control it.... e.g. I may have to write a few of my own functions for it)

I could also do all this stuff with just the standard DOUTs but then I lose the ability to easily control the broghtness of each led matrix I drive. I want to use three cascaded max7221 chips to drive an rgb led matrix of 8x8. It is nice that each one only needs a single resistor value to set the brightness of the whole colour.

I could also do this with the 74HC595 by pwm the chip enable pin  BUT how do I program this into mios? what pin do I use as the pwm output? Should I get a dedicated square wave generator to do this? If so, how do I control it with software?

Link to comment
Share on other sites

Controlling a MAX7221 via DOUT interface requires a lot of programming skills, because you need to know, how to write a "sequential state machine" which controls the register write accesses on each SRIO update cycle.

PWM: see this article

However, I think, that the application has enough spare pins to drive the chip via GPIOs (only the CS# line should be a dedicated output, all others can be shared).

The README describes, how to adapt the pins - it's easy!

Best Regards, Thorsten.

Link to comment
Share on other sites

heheh EASY for you! ;)

Those pins (from port C) are being used by the AIN module no? (J6 on the core).  What other pins could I use as GPIO?

With something like Arduino it is so clear what one has assigned to each pin and how those pins will be used. I guess with MIOS I am still getting lost between what has already been pre-allocated in MIOS and what I can override or assign with my C apps. Still hazy on elements of the big picture...

Also I don't know what LATC and TRISC are.

I assume "shared with other outputs" means that two of those pins can use a port/pins that will also be used for other purposes (they take turns) but the CS pin needs to be dedicated.

I may be missing something really obvious or simple about how to integrate this into MB64 or simmilar app that has AIN, DIN and DOUT modules attached to it.

thanks!

Link to comment
Share on other sites

With something like Arduino it is so clear what one has assigned to each pin and how those pins will be used. I guess with MIOS I am still getting lost between what has already been pre-allocated in MIOS and what I can override or assign with my C apps. Still hazy on elements of the big picture...

I guess, that you missed the pin list: http://www.ucapps.de/mios/mios_pin_list.txt

I would propose to start with pin RC4, RC5, RD4 (I guess, that you are not using touch sensors)

In order to assign these pins, add following lines to the Makefile:

[tt]

# include MAX72xx driver

MAX72XX_DEFINES += -DMAX72XX_CHAINLENGTH=1

MAX72XX_DEFINES += -DMAX72XX_LAT_CS=LATC -DMAX72XX_TRIS_CS=TRISC -DMAX72XX_PIN_CS=4

MAX72XX_DEFINES += -DMAX72XX_LAT_SCLK=LATC -DMAX72XX_TRIS_SCLK=TRISC -DMAX72XX_PIN_SCLK=5

MAX72XX_DEFINES += -DMAX72XX_LAT_DIN=LATD -DMAX72XX_TRIS_DIN=TRISD -DMAX72XX_PIN_DIN=4

include $(MIOS_PATH)/modules/max72xx/max72xx.mk

[/tt]

LATx and TRISx are described in the PIC datasheet. For you it's probably sufficient to know, that they control the pin output value and tristate driver

Btw.: this is how you can add the driver into a C application. I assume that you will do the first experiments in C to save time. I'm currently a bit too lazy to describe the differences between defining constants in assembly (which would be done in main.inc) and in C (where it is done in the makefile)

However, the AOUT driver is a nice example which shows the differences (e.g., have a look into the most recent MBSID/MBFM/MBSEQ or MBCV code)

All the documentation issues are btw. a big blocking point for me, which prevents me from releasing the programming platform. I fear, all the different possibilities makes it too complicated. :(

Best Regards, Thorsten.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...