Jump to content
43oh

First Serial w/ 8x8 led matrix


Recommended Posts

I jacked RobG's serial code from his 16 LED post and played with it some... Will probably play with it much more :) This is what I've done so far...

 

 

One 74HC595 controls rows and one controls columns. Each pixel is a bit, each column is a byte, each row is a char in an array... Was the best I could think of to minimize it. It's a tad messy because I was doing different things and still am :-x But YaY, it does something :)

 

// This is RobG's 16 led & 2 74HC595's code modified and played with...
// A little messy and lacking commentary.
#include "msp430g2231_mod.h"

unsigned short TickCntr = 0;
unsigned char CurCol = 0;
unsigned char CurColAdd = 0;
unsigned char CurRow = 0;

// " M S P 4 3 0 " in 5x7 vertical binary to decimal
unsigned char data[36] = {127,32,24,32,127,0,50,73,73,73,38,0,127,72,72,72,48,0,12,20,36,127,4,0,34,65,73,73,54,0,62,69,73,81,62,0};
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

BCSCTL1 = CALBC1_16MHZ;                // Set range  
DCOCTL = CALDCO_16MHZ;                 // Set DCO step + modulation

P1OUT |= 0x01;                      // Port P1.0 will be used to latch
P1DIR |= 0x01;

USICTL0 |= USIPE6 + USIPE5 + USIMST + USIOE; // Out & clk enable, SPI Master
USICTL1 |= USICKPH + USIIE;               // Counter interrupt
//	USICKCTL = USIDIV_7 + USISSEL_2;          // /2 SMCLK
USICKCTL = USIDIV_0 + USISSEL_2;          // /2 SMCLK
USICTL0 &= ~USISWRST;                     // Enable USI
USICNT = USI16B;                           // Enable 16 bit

CCTL0 = CCIE;                             // CCR0 interrupt enabled
CCR0 = 272;                        // Duration (16*16+16, I don't know the reasoning but it's what appears to be the lowest that works with some buffer in case of delays)
//	TACTL = TASSEL_2 + MC_1 + ID_3;           // SMCLK, upmode
TACTL = TASSEL_2 + MC_1 + ID_0;           // SMCLK, upmode

_bis_SR_register(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt
}

// Timer A0 interrupt service routine
#pragma vector = TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
unsigned int Output = 0xFF00; // make it blank in case of an error
TickCntr++; // count the ticks
if(TickCntr>9000) // did we hit 9000 ticks?
{ // We did, lets reset and increase the column for rotation
	TickCntr=0;
	CurCol++;
	CurColAdd = 0; // this helps with some jitter since I didn't do a smoother method
	if(CurCol>35)CurCol = 0;
}
CurRow>>=1; // bitwise shift the row from last go around
if((CurCol+CurColAdd)>35) // make sure we don't try to read more than we should
{
	if((CurRow&data[(CurCol+CurColAdd)-36]) == CurRow) // go back to 0 column
	{
		Output = CurRow^0xFF; // XOR the row
		Output<<=8; // shift the row data over
		Output |= (0x80>>CurColAdd); // Shift the column into place
	}
}
else
{
	if((CurRow&data[CurCol+CurColAdd]) == CurRow) // repeat but without the minus
	{
		Output = CurRow^0xFF;
		Output<<=8;
		Output |= (0x80>>CurColAdd);
	}
}
if(CurRow==0) // if we did the last row lets reset that
{
	CurRow=0x80;
	CurColAdd++; // increase the column we're working on
	if(CurColAdd>7)CurColAdd=0; // reset the column we're working on
}
USISR = Output; //USISR = unsigned int (16 bits)
USICNT |= 16;                              // Start USI
}

// USI interrupt service routine
#pragma vector = USI_VECTOR
__interrupt void USI_TXRX (void)
{
USICTL1 &= ~USIIFG;                     // Clear pending flag
P1OUT &= ~0x01;                     // Latch data
P1OUT |= 0x01;
}

Link to post
Share on other sites
but this 8x8 matrix pinout seems kind of weird to me

 

It took me several months and reverse-engineering several displays before I finally figured out the bizarre pinouts they have. With at least the ones I worked with, they're rotationally symmetric; You can unplug it, rotate it 180 degrees, and plug them back in and they still work!

 

Blew my mind.

Link to post
Share on other sites

The way I figured it... 1->16: GR5, GR7, PC2, PC3, GR8, PC5, GR6, GR3, GR1, PC4, PC6, GR4, PC1, GR2, PC7, PC8. (Ground Row, Positive Column), with the pins face-up and the text on the side pointing away from you. Although it's really perspective since I did it in one direction, hehe.

 

http://www.futurlec.com/LED/LEDMS88R.shtml

Link to post
Share on other sites
  • 1 month later...

That didn't have a schematic, it was just thrown together on a breadboard to get the general idea for another project that I have boards on order for.

 

For a bicolor matrix you could go with 3 74hc595's in series with 1 smaller msp430 controlling it per 8x8 matrix. That would be 12 74hc595's and 4 msp430's (bit bang it with cheaper ones and little memory), and then have a 5th msp430 that has more power (mostly just more memory!) that controls those 4. This is basically what I'm doing with my next project. I'll post it soon'ish :) I'm doing a 9x9 of 8x8's with 1 msp430g2231 & 2 74hc595's per 8x8. Looking at using f2274 for the controller for testing but might try to figure out a different solution to the controller for easy user interaction.

Link to post
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.

×
×
  • Create New...