Note that there are some explanatory texts on larger screens.

plurals
  1. POC array is displaying garbage data (memory problems?)
    primarykey
    data
    text
    <p>I'm making a driver for an 8x8 LED matrix that I'm driving from a computer's parallel port. It's meant to be a clock, inspired by a design I saw on Tokyoflash. </p> <p>Part of the driver is an array of 3*5 number "sprites" that are drawn to the matrix. A coordinate of the matrix is assigned to a coordinate of the sprite and so forth, until the entire sprite is drawn on it. This process is repeated for the other digit with an offset. I have verified I have drawn the sprites correctly, and that the matrix is blank when it is written to. However, when I draw a number on the matrix I get errant 1s at Numpad6 for the left digit, Numpad1 for the right (<a href="http://img7.imageshack.us/img7/8490/hahawhattehf.png" rel="nofollow noreferrer">Example with the left digit not drawn.</a>)</p> <p>I have a week of experience in C and this is baffling me.</p> <p>Here is the driver in full if you want to compile it yourself. It is nowhere near finished.</p> <pre><code>//8x8 LED MATRIX DRIVER VER 0.1 APR062009 //CLOCK // // 01234567 // 0 BXXXXXXH B: Binary Mode Indicator // 1 DXXXXXXM D: Decimal Mode Indicator // 2 NNNNNNNN H: Hour Centric Display // 3 LLLNNRRR M: Minute Centric Display // 4 LNLNNRNR X: Secondary Information // 5 LLLNNRRR L: Left Digit // 6 LNLNNRNR R: Right digit // 7 LLLNNRRR N: Not Used #include &lt;stdio.h&gt; #include &lt;unistd.h&gt; //#include &lt;math.h&gt; #include &lt;time.h&gt; #include &lt;/usr/include/sys/io.h&gt; #define BASEPORT 0x378 int main() { //Increasing array parameters to seems to reduce glitching [best 10 5 3] int Dig[10][5][3] = {0}; //ALPHANUMERIC ARRAY [NUMBER (0..9)][Y(0..4)][X(0..2)] int Mat[7][7] = {0}; //[ROW][COL], Top L corner = [0][0] int Aux1[7] = {0}; //Topmost Row int Aux2[7] = {0}; //Second to Topmost Row int Clk; //Clock int Wait; //Delay; meant to eventually replace clock in its current state int C1; //Counters int C2; int C3; int L; //Left Digit int R; //Right Digit //break string left undefined atm //ioperm (BASEPORT, 3, 1); //outb(0, BASEPORT); printf("Now running.\n"); //Set Variables //3D DIGIT ARRAY [Num][Row][Col] (INITIALIZED BY INSTRUCTIONS) //Dig array is meant to be read only once initialized //3D arrays are unintuitive to declare so the numbers are //"drawn" instead. //Horizontals //Some entries in the loop may have the variable in the middle //coordinate instead of the 3rd and/or with a +2. This is to //incorporate the incomplete columns some numbers have (eg "2") and //saves coding additional loops. for(C1=0; C1&lt;=2; C1++){ Dig[0][0][C1]=1; Dig[0][4][C1]=1; Dig[2][0][C1]=1; Dig[2][2][C1]=1; Dig[2][4][C1]=1; Dig[2][C1][2]=1; Dig[2][C1+2][0]=1; Dig[3][0][C1]=1; Dig[3][2][C1]=1; Dig[3][4][C1]=1; Dig[4][2][C1]=1; Dig[4][C1][0]=1; Dig[5][0][C1]=1; Dig[5][2][C1]=1; Dig[5][4][C1]=1; Dig[5][C1][0]=1; Dig[5][C1+2][2]=1; Dig[6][0][C1]=1; Dig[6][2][C1]=1; Dig[6][4][C1]=1; Dig[6][C1+2][2]=1; Dig[7][0][C1]=1; Dig[8][0][C1]=1; Dig[8][2][C1]=1; Dig[8][4][C1]=1; Dig[9][0][C1]=1; Dig[9][2][C1]=1; Dig[9][4][C1]=1; Dig[9][C1][0]=1; } //Verticals for(C1=0; C1&lt;=4; C1++){ Dig[0][C1][0]=1; Dig[0][C1][2]=1; Dig[1][C1][2]=1; Dig[3][C1][2]=1; Dig[4][C1][2]=1; Dig[6][C1][0]=1; Dig[7][C1][2]=1; Dig[8][C1][0]=1; Dig[8][C1][2]=1; Dig[9][C1][2]=1; } Clk=10000; L=2; //Think about incorporating overflow protection for L,R R=4; //Print Left Digit to Matrix @ (3, 0) for(C1=0; C1&lt;=4; C1++){ //For some reason produces column of 1s at numpad 6 for(C2=0; C2&lt;=2; C2++){ Mat[C1+3][C2]=Dig[L][C1][C2]; printf("%d", Dig[L][C1][C2]); //Debug } printf(" %d %d %d\n", L, C1, C2); //Debug } //Print Right Digit to Matrix @ (3, 5) for(C1=0; C1&lt;=4; C1++){ //For some reason produces column of 1s at numpad 1 for(C2=0; C2&lt;=2; C2++){ Mat[C1+3][C2+5]=Dig[R][C1][C2]; } } //X Test Pattern //for(C1=0; C1&lt;=7; C1++){ // Mat[C1][C1]=5; // Mat[7-C1][C1]=5; //} usleep(Clk); //while(1){ //Breakfree [NOT FUNCTIONAL] //Break_String=getch(); (Getch is not ANSI, need ncurses) //if(Break_String != -1){ // if(Break_String = 27){ // break; // } //} //Terminal Display //for(C3=0; C3&lt;=9; C3++){ //Debug Digit array [Successful, numbers draw correctly] // for(C2=0; C2&lt;=4; C2++){ // for(C1=0; C1&lt;=2; C1++){ // printf("%d", Dig[C3][C2][C1]); // } // printf("\n"); // } //printf("\n"); //usleep(1000000); //Debug //} usleep(3000000); //Debug for(C1=0; C1&lt;=7; C1++){ //Prints to terminal every second, when looping for(C2=0; C2&lt;=7; C2++){ printf("%d", Mat[C1][C2]); } printf("\n"); } printf("\n"); //Hardware Display for(C1=0; C1&lt;=29; C1++){ //30 Hz for(C3=0; C3&lt;=7; C3++){ //COLUMN //printf("%d %d \n", C3, C1); //Loop Debug usleep(1000); //CLOCK GROUND TO GO HERE, OUT STATUS //for(C2=0; C2&lt;=7; C2++){ //PX //outb(Mat[C3][C2], BASEPORT); //} } usleep(4*Clk); } //} //ioperm(BASEPORT, 3, 0); exit(0); } </code></pre> <p>Also, I had to make my Sprite array bounds each one bigger than they should have been to make it work. I figure this is all some some memory snafu but I'm nowhere near that proficient in C to know what to do.</p> <p>I would greatly appreciate any help. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload