mtlevine0 14 Posted June 15, 2011 Share Posted June 15, 2011 I constructed a simple 8x8 LED matrix display using two 74595 shift registers to drive the rows and columns. I created an array to output to the display. I have it scrolling some characters (currently two, I plan to expand it to many more with the addition of an I2C EEPROM). The uC is running @ 1MHZ off of the internal DCO, could this be too slow? The code works and the matrix displays what it I told it to BUT there are undesired "ghost" pixels which flicker on and off in a pattern. I have switched out the 74595 registers and that didn't seem to fix it. Has anyone seen this before and know how to fix it? Here is a video of it in operation. The code is posted bellow. The video quality is poor but the horizontal "ghosting" is still very evident, the random vertical lines are also occurring and are not just an affect of the poor frame rate. #include #define CLOCK BIT4 #define DATA BIT5 #define LATCH BIT3 #define delayLoop 15 #define arrayLength 13 void delay(unsigned int ms); void pulseClock(void); void shiftOut(char val); void pinWrite(unsigned int bit, unsigned char val); const char index[8] = {0x74,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE}; const char font[arrayLength][8] ={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x20, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x20, 0x10, 0x20, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x20, 0x10, 0x20, 0x7f, 0x00, 0x00, 0x31, 0x00, 0x7f, 0x20, 0x10, 0x20, 0x7f, 0x00, 0x49, 0x31, 0x00, 0x7f, 0x20, 0x10, 0x20, 0x7f, 0x49, 0x49, 0x31, 0x00, 0x7f, 0x20, 0x10, 0x20, 0x49, 0x49, 0x49, 0x31, 0x00, 0x7f, 0x20, 0x10, 0x46, 0x49, 0x49, 0x49, 0x31, 0x00, 0x7f, 0x20, 0x00, 0x46, 0x49, 0x49, 0x49, 0x31, 0x00, 0x7f}; void main (void){ BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; WDTCTL = WDTPW + WDTHOLD; // Disable WDT P1DIR |= (CLOCK + DATA + LATCH); // Set P1DIR while(1){ int i, j, t; for(j = 0; j < arrayLength; j++){ for(t = 0; t < delayLoop; t++){ for(i = 0; i < 8; i++){ pinWrite(LATCH,0); shiftOut(index[i]); shiftOut(font[j][i]); pinWrite(LATCH,1); } } } } } void delay(unsigned int ms){ while (ms--){ __delay_cycles(1000); } } void pulseClock(void){ P1OUT |= CLOCK; P1OUT ^= CLOCK; } void shiftOut(char val){ //P1OUT &= ~LATCH; char i; for(i = 0; i < 8; i++){ pinWrite(DATA, (val & (1 << i))); pulseClock(); } //P1OUT |= LATCH; //P1OUT &= ~LATCH; } void pinWrite(unsigned int bit, unsigned char val){ if(val){ P1OUT |= bit; }else{ P1OUT &= ~bit; } } Quote Link to post Share on other sites
RobG 1,892 Posted June 15, 2011 Share Posted June 15, 2011 I would try changing those 2 things void pulseClock(void){ P1OUT |= CLOCK; P1OUT &= ~CLOCK; } for(i = 0; i < 8; i++){ shiftOut(index[i]); shiftOut(font[j][i]); pinWrite(LATCH,1); pinWrite(LATCH,0); } Quote Link to post Share on other sites
mtlevine0 14 Posted June 16, 2011 Author Share Posted June 16, 2011 no luck with those modifications. Quote Link to post Share on other sites
RobG 1,892 Posted June 16, 2011 Share Posted June 16, 2011 Can you post schematic? Quote Link to post Share on other sites
nexusone1984 32 Posted June 21, 2011 Share Posted June 21, 2011 Here is how I write to my 74hc595, and I am running at 1Mhz. When writing to the 74HC595, I always put the latch on logic 0. And shift data in from the going from logic 0 to logic 1 on the clock pin. Then at the end of my shifting in data, put the latch pin to logic 1. If I am looking at your code correctly, your clocking High to low on you clock pin when shifting in. Try going from low to high. I had to re-edit this part. If you need a delay use a the delay call for ms delay or maybe a 'for' statement after shifting in the data. for(j = 0; j < arrayLength; j++) { for(t.......) // this part in the program is ok { for(i = 0; i < 8; i++) { pinWrite(LATCH,0); shiftOut(index); shiftOut(font[j]); pinWrite(LATCH,1); // short ms delay here maybe would help... } } } Also check for loose wires and make sure you don't have any floating logic pins... mtlevine0 1 Quote Link to post Share on other sites
jsolarski 94 Posted June 21, 2011 Share Posted June 21, 2011 it looks like a similar problem i had with a 3 digit display that was multiplexed. My issue was switching two fast and the display would ghost with the digits next to it. I found 2 solutions which may help you. One is set a longer delay between character writes/column writes. Adding a few more ms to a delay may work. You will have to play around with it to find the spot that needs the delay, but my guess is after the shiftouts but before that for loop ends the other may not work for you since I dont know what your circuit looks like, but I also added some pulldown resistors on the data lines, but i was using transistors to multiplex my display. (8 character lines + 3 multiplex lines) after doing this i was able to run it much faster, but i lost some brightness on faster speeds.----- maybe use the built in pulldowns/pullups? remember to use the one for the correct initial state- (IE latch - low = pulldown ) mtlevine0 1 Quote Link to post Share on other sites
mtlevine0 14 Posted July 1, 2011 Author Share Posted July 1, 2011 Thanks for the tips guys I'll try those out soon. Haven't found a good schematic drawling program anyone have any suggestions for a free one? Quote Link to post Share on other sites
SugarAddict 227 Posted July 2, 2011 Share Posted July 2, 2011 Eagle. Quote Link to post Share on other sites
SugarAddict 227 Posted July 2, 2011 Share Posted July 2, 2011 const char index[8] = {0x74,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE}; I'm guessing that should actually be a 0x7F instead of 0x74? Double check your font data, are you using 1 led at a time? or multiple leds? bluehash and mtlevine0 2 Quote Link to post Share on other sites
mtlevine0 14 Posted July 4, 2011 Author Share Posted July 4, 2011 const char index[8] = {0x74,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE}; I'm guessing that should actually be a 0x7F instead of 0x74? Double check your font data, are you using 1 led at a time? or multiple leds? That fixed everything. I've found myself mixing up 'F' and '4' before when dealing with HEX numbers... Quote Link to post Share on other sites
SugarAddict 227 Posted July 4, 2011 Share Posted July 4, 2011 It happens Quote Link to post Share on other sites
nuetron 64 Posted July 4, 2011 Share Posted July 4, 2011 Haven't found a good schematic drawing program anyone have any suggestions for a free one? See this thread. I've had pretty good results with Eagle, seems to be lacking some older and newer devices, though. Here's the library I created for the 'G2231, same pinout as 'G2211. If/when you get Eagle installed, just extract the zip into the lbr folder in the Eagle install folder. msp430g2231.zip gordon 1 Quote Link to post Share on other sites
SugarAddict 227 Posted July 5, 2011 Share Posted July 5, 2011 TI has a library for all of the MSP430's... (All I've needed to use and then some...) MSP430 schematic symbols and footprints library for use with the Eagle CAD tool (Rev. E) nuetron and oPossum 2 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.