SugarAddict 227 Posted February 16, 2011 Share Posted February 16, 2011 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; } RobG, bluehash and jsolarski 3 Quote Link to post Share on other sites
bluehash 1,581 Posted February 16, 2011 Share Posted February 16, 2011 Awesome, Thanks for sharing. It would be nice if you comment the rate your timer is set at. I'm moving this to Projects. Quote Link to post Share on other sites
SugarAddict 227 Posted February 16, 2011 Author Share Posted February 16, 2011 Ok, I updated it. :-D I'm guessing the 16*16+16 delay I'm using is serial or shift register related. It gets messy if I go much lower than 256 (16*16) If I knew how to make a part in eagle I would drop a schematic... but this 8x8 matrix pinout seems kind of weird to me and I didn't see any in there. Quote Link to post Share on other sites
PhirePhly 5 Posted February 16, 2011 Share Posted February 16, 2011 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. Quote Link to post Share on other sites
SugarAddict 227 Posted February 16, 2011 Author Share Posted February 16, 2011 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 Quote Link to post Share on other sites
bluehash 1,581 Posted February 16, 2011 Share Posted February 16, 2011 It would be no harm if you submit it to the Project of the Month contest. Quote Link to post Share on other sites
MystBoy 5 Posted April 5, 2011 Share Posted April 5, 2011 can you pls post your shematic? im intrested in doing something like this with 4 bicolour 8x8 led matrix so it will be 16x16 thx! Quote Link to post Share on other sites
SugarAddict 227 Posted April 5, 2011 Author Share Posted April 5, 2011 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. Quote Link to post Share on other sites
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.