Bnj
Remember; amateurs built the Ark, professionals built the Titanic.
Hallo heren,
ik heb een 8x8 LED-matrix gemaakt met daarin RGB LEDs (common anode) die aangesloten zitten op current-sink schuifregisters en de anode hangt aan een I/O expander. Alles werkt naar behoren maar mijn probleem is het volgende.
Om plaatjes op te slaan wil ik flash geheugen gebruiken en wel de M25P80 van STmicroelectronics.
Datasheet:http://www.st.com/stonline/books/pdf/docs/8495.pdf
In het schrijven/lezen van en naar het geheugen gaat er echter iets niet helemaal goed.
Om het geheugen te testen schrijf ik waardes in een tabel weg voor alle kleuren om uiteindelijk een witte B weer te geven op de matrix. Dit doe ik op de volgende manier:
void flash_write_progress(void)
{
P1OUT|=0x01; //turn led on
P1OUT&= ~0x04; //#CS low
USISRH=0x05; //RDSR (Read status register) instruction code
USICNT|=8; // re-load counter without touching USI16B
while (!(USIIFG & USICTL1)); // Counter clear?
USICNT|=8; // re-load counter without touching USI16B
while (!(USIIFG & USICTL1)); // Counter clear?
while((USISRH|0xFE)==0xFF)
{
USICNT|=8; // re-load counter without touching USI16B
while (!(USIIFG & USICTL1)); // Counter clear?
}
P1OUT|=0x04; //#CS high
P1OUT&= ~0x01; //turn led off
}
short int r[SIZE]; //SIZE-places in array to store bytes for one frame (image)
short int g[SIZE];
short int b[SIZE];
const int last_byte = 0x00;
//fill arrays with values for a frame displaying B
r[0]=0x3c;
r[1]=0x44;
r[2]=0x44;
r[3]=0x44;
r[4]=0x3c;
r[5]=0x44;
r[6]=0x44;
r[7]=0x3c;
for(i=0; i<SIZE; i++)
{
l=r[i];
g[i]=l;
b[i]=l;
}
//Page program sequence
//red color first, then green color, then blue color
// --> for each image(frame) we need 3x8=24 bytes
P1OUT&= ~0x04; //#CS low
USISRH=0x06; //WREN (Write enable)
USICNT|=8; // re-load counter without touching USI16B
while (!(USIIFG & USICTL1)); // Counter clear?
P1OUT|=0x04; //#CS high
Delay(5000); //latch-bit already set?
P1OUT&= ~0x04; //#CS low
USISRH=0x02; //PP (Page Program)
USICNT|=8; // re-load counter without touching USI16B
while (!(USIIFG & USICTL1)); // Counter clear?
USISR=0x0000; // first 2 bytes of adress
USICNT|=16;
while (!(USIIFG & USICTL1)); // Counter clear?
USISRH=last_byte; // last byte of adress
USICNT|=8;
while (!(USIIFG & USICTL1)); // Counter clear?
for(i=0; i<SIZE; i++)
{
USISRH=r[i]; //
USICNT|=8;
while (!(USIIFG & USICTL1)); // Counter clear?
}
for(i=0; i<SIZE; i++)
{
USISRH=g[i]; //
USICNT|=8;
while (!(USIIFG & USICTL1)); // Counter clear?
}
for(i=0; i<SIZE; i++)
{
USISRH=b[i]; //
USICNT|=8;
while (!(USIIFG & USICTL1)); // Counter clear?
}
P1OUT|=0x04; //#CS high
flash_write_progress();
for(i=0; i<SIZE; i++) //clear arrays
{
r[i]=0x00;
g[i]=0x00;
b[i]=0x00;
}
//Read sequence to read out written data
P1OUT&= ~0x04; //#CS low
USISRH=0x03; //READ (Read data bytes)
USICNT|=8; // re-load counter without touching USI16B
while (!(USIIFG & USICTL1)); // Counter clear?
USISR=0x0000; // first 2 bytes of adress
USICNT|=16;
while (!(USIIFG & USICTL1)); // Counter clear?
USISRH=last_byte; // last byte of adress
USICNT|=8;
while (!(USIIFG & USICTL1)); // Counter clear?
for(i=0; i<SIZE; i++)
{
USICNT|=8; //shift in 1 byte
while (!(USIIFG & USICTL1)); // Counter clear?
l=USISRH;
r[i]=l; //fill array with value retrieved, at position i
}
for(i=0; i<SIZE; i++)
{
USICNT|=8; //shift in 1 byte
while (!(USIIFG & USICTL1)); // Counter clear?
l=USISRH;
g[i]=l; //fill array with value retrieved, at position i
}
for(i=0; i<SIZE; i++)
{
USICNT|=8; //shift in 1 byte
while (!(USIIFG & USICTL1)); // Counter clear?
l=USISRH;
b[i]=l; //fill array with value retrieved, at position i
}
P1OUT|=0x04; //#CS high
Het probleem is nu dat er wel een B op het display komt te staan alleen schuift de data 1 rij in de matrix naar boven op. We krijgen dus een verschoven B te zien.
Wanneer ik de data los naar de matrix schrijf dan werkt het wel.
Heeft iemand een idee?
treinfreak
Look at me, I can't fly.....
klinkt als een lus die begint met de verkeerde waarde. Ik kan uit jouw code zo 1-2-3 niet halen waar het aan liggen kan maar zo klinkt het probleem.