rvlt Posted March 27, 2012 Report Share Posted March 27, 2012 Hey, is there a way / a driver to access a MAX72xx under MIOS32? I know there is a MAX72xx driver in the svn in the MIOS8 path, but none for MIOS32. The reason I'm asking is that I have a midibox'ed Tascam MMRC (with a few MAX7219), and i'd like to put a LPC17 (USB, Ethernet..) in there instead of my Pic Core. Best regards Lars Quote Link to comment Share on other sites More sharing options...
rvlt Posted June 6, 2012 Author Report Share Posted June 6, 2012 Hello, some more questions about the MAX72xx driver, this time on MIOS8 with a PIC-Core. ** First of all I must say that I'm a totally newbie when it comes to programming. I've managed to get my Tascam up and running (buttons and button matrix, some single leds..), but addressing LEDs with the MAX-driver is way over my head.** So, what I'm basicially looking for is a simply way to turn LEDs on and off via note on/off events. If I want to control LEDs directly connected to DOUTs I use the "MIOS_DOUT_PinSet" function. Is there some kind of equivalent in the MAX72xx driver? I messed around with the stribe project a bit, and I guess the "STRIBE_SetDot" function is what I'm looking for, but there are some problems: a) there is only one LED at a time lit, as soon as I press another note the first LEDs turns off, and b) there are three MAX7219, and I don't know how to address each chip separately. So before digging around in the stribe code too much, is there a simple way to use LEDs via MAX7219s by just using the driver (without any stribe stuff)? Best regards Lars Quote Link to comment Share on other sites More sharing options...
TK. Posted June 7, 2012 Report Share Posted June 7, 2012 This is some untested code which should allow to set/clear an individual bit: void STRIBE_SetLED(unsigned char stribe, unsigned char lr, unsigned char led, unsigned char value) __wparam { unsigned char and_mask, or_mask, offset; or_mask = lr << ((stribe&3)<<1); and_mask = ~or_mask; offset = ((stribe&4)<<4); INTCONbits.GIE = 0; // temporary disable IRQs to avoid clash with STRIBE_Timer() // set or clear LED state? if( value ) max72xx_digits[offset+63-led] |= or_mask; } else { max72xx_digits[offset+63-led] &= and_mask; } INTCONbits.GIE = 1; stribe_flags.LED_UPDATE_REQ = 1; } [/code] I hope that it says more than an abstract description of the required implementation... Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
rvlt Posted June 7, 2012 Author Report Share Posted June 7, 2012 Wow, thanks! Now it works, I mean on/off & multiple leds. The only thing left is addressing the different chips individually, right now the leds on all three 7219 light up at the same time. When I use a different stribe number via STRIBE_SetLED(...) , only some other leds are addressed on the same 7219, but not a different 7219. I guess i that could be either.. - because compared to the stribe project i have 7219s and not 7221 ? (Is there a difference between LOAD/CS?) - on my tascam pcb the DIN on all 7219 are connected together rather than a DIN > DOUT chain from one chip to another - I have a PIC18F4620 and no PIC18f452 installed right now (I could change that..) I could give more details later, but have to work now. Gotta hurry.... Thanks TK ! Quote Link to comment Share on other sites More sharing options...
TK. Posted June 7, 2012 Report Share Posted June 7, 2012 7219 isn't hardware-compatible to the 7221, because it uses a different protocol to access the registers. Unfortunately I've neither 7219 for testing, nor the time to develop a different driver for these chips + debug this remotely (with your help) Are you able to replace the chips and to change the wiring to a DIN->DOUT chain? If not, somebody else has to help you here, or you have to learn assembler! ;-) Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
rvlt Posted June 7, 2012 Author Report Share Posted June 7, 2012 (edited) Ah ok, I see. Unfortunately the 7219 are all SMD, but for me still easier to desolder and put 7221 in than learning assembler ;) Reichelt has them in stock, so I think I'll go this route. About the DIN/DOUT: is this really necessary to create a chain? I'm just asking because Tascam didn't use the DOUTs at all on their PCB. The datasheet says the signal at DIN is the same at DOUT, only "16.5 cycles later." Don't know if this is important for your driver. Leaving the DINs like they are now would save from cutting a few PCB traces. But still doable though.. Thanks for your help Lars Edited June 7, 2012 by rvlt Quote Link to comment Share on other sites More sharing options...
rvlt Posted June 16, 2012 Author Report Share Posted June 16, 2012 Success!! I soldered 7221 on the board (was SMD but not as tough as I thought) and now I can access every single led. At first I left the DINs in parallel as they were before, and the behavior was exactly the same as with the 7219, but when I changed to a DIN>DOUT chain it worked. Mapping is still a bit weird (have to access stribe numbers 0,1,2 & 3, but I only have three 7221 at all), but anyway... :thumbsup: Best regards Lars Quote Link to comment Share on other sites More sharing options...
rvlt Posted June 28, 2012 Author Report Share Posted June 28, 2012 Hi, has anyone an idea how to implement a "delay" or "lag" function for LEDs? Background: My Tascam Remote now "speaks" the Mackie protocol, and I want to make use of the signal LEDs found on the original hardware. According to the manual the host software sends midi channel pressure commands which turn on the signal LED for about 300ms. So, what i basically need is a function which turns the LED off after a period of time (without receiving any other midi message). Right now I have something like this: ///////////////////////////////////////////////////////////////////////////// // This function is called by MIOS when a complete MIDI event has been received ///////////////////////////////////////////////////////////////////////////// void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam { if( evnt0 == 0xD0 && evnt1 >= 0x01 && evnt1 <= 0x0C ) // receive Channel pressure for Ch.1 { STRIBE_SetLED(2, 2, 0x37, 1); // turns on LED ????; // some delay function... ??? STRIBE_SetLED(2, 2, 0x37, 0); // turns off LED } } I read some thread about people using SR_Service_Prepare to do that but I guess in my case this wouldn't work because all my LEDs are connected via MAX7221. I also fooled around with the MIOS_Delay but it didn't work. I guess I must use Timer or Tick but I have no clue how to do that. Best regards Lars Quote Link to comment Share on other sites More sharing options...
TK. Posted July 1, 2012 Report Share Posted July 1, 2012 Hi Lars, you need: an array which stores counter values for each LEDa timer (see mios32_timer tutorial) which decrements these counters as long as they are > 0 - it could be called each mS. Note that there is already a function which is called each mS which you could re-use for such a purpose: APP_SR_Service_Prepare()!a task which periodically updates the MAX7221 whenever the state of a LED has changed. This task should also set LEDs as long as the appr. counters are 0your MIDI receiver sets a counter to 300 -> the timer will decrement the counter each mS, your task will notify this and update the LED accordingly. Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
rvlt Posted July 2, 2012 Author Report Share Posted July 2, 2012 Thanks Thorsten! I will report back when I have something useful. Lars Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.