hello,
I probably exhumed an old thread by posting that: http://www.midibox.o…index.php/topic,12786.msg121206/topicseen.html#msg121206
so I’d prefer to repost another topic.
1 DOUT where the first SR is connected to 1 ULN2803 with his pin 9 to GND (pin 10 not connected to anything)
the purpose is the handling of a 8x8 RGB common cathode led matrix.
the code comes from ain64_din128_dout128 apps.
SR_Service_Prepare has been modified to handle the ULN to cycle the matrix.
it doesn’t work.
I guess it should, because noofny/mike did… we have the same code, and almost the same hardware…
BUT, he chained his 2 DOUT on the same core, I have 1 DOUT per core.
the code has been altered to fit with my hardware, of course.
but I may missed something.
the code part to look at are :
void DisplayLED(unsigned char column, unsigned char color) __wparam
{
color >>= 4;
MIOS_DOUT_PinSet(column+8, (color & 0x01)); // RED
color >>= 1;
MIOS_DOUT_PinSet(column+8+8, (color & 0x01)); // BLUE
color >>= 1;
MIOS_DOUT_PinSet(column+8+8+8, (color & 0x01)); // GREEN
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS before the shift register are loaded
/////////////////////////////////////////////////////////////////////////////
void SR_Service_Prepare(void) __wparam
{
// HELPED BY BUGFIGHT ON MIDIBOX - http://www.midibox.org/forum/index.php/topic,12786.0.html
static unsigned char row;
unsigned int x; //edit* just noticed, no reason for this to be static
row = ++row & 0x07; //<-- here you were cycling 16 rows i think you meant 8, no?
//this would have resulted in a 6.25% duty cycle (vs 12.5%).
//note that the duomatrix uses a 25% duty cycle
MIOS_DOUT_SRSet(_MATRIX_DOUT_START, 0); //<-- hardwire bad, napster good. define constants
// so you can move your matrix in the chain
MIOS_DOUT_PinSet1(row);
for (x = 0; x < 8; x++)
{
DisplayLED(x , matrix[row][x]);
}
}
_MATRIX_DOUT_START is 0 in each case cause ULN is on the 1st SR.
NUMBER_OF_SRIO is defined to 12 cause I have 2 DIN + 1 DOUT on the core considered here (2x4 + 1x4 = 12)
I have big doubts about these constants.
I saw that: http://www.midibox.o…=din&s=dout
probably, I don’t activate the correct pin…
if someone could point me in the right way, it would be very great and interesting ![]()
I attached my main.c and my main.h
[main.c](< base_url >/applications/core/interface/file/attachment.php?id=5483)
[main.h](< base_url >/applications/core/interface/file/attachment.php?id=5484)
[main.c](< base_url >/applications/core/interface/file/attachment.php?id=6536)
[main.h](< base_url >/applications/core/interface/file/attachment.php?id=6537)