I am working on a display project and am trying to test out displaying characters using an 8X8 array. When I put the this test program in, I get the following result, which is totally wrong as is aprent in the definition of the array. I am using THe latest version of MPLAB, the latest version of CCS's PIC MCU C compiler, and a PIC16F877A from CCS.
Code:
#include <16F877A.h>
#include <stdlib.h>
#include <stdint.h>
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#define button PIN_A4
short A[8][8] =
{
{0,0,0,1,1,0,0,0}
{0,0,1,0,0,1,0,0}
{0,0,1,0,0,1,0,0}
{0,1,0,0,0,0,1,0}
{0,1,0,0,0,0,1,0}
{0,1,1,1,1,1,1,0}
{0,1,0,0,0,0,1,0}
{0,1,0,0,0,0,1,0}
};
int i,j;
void waitpress()
{
while(input(button));
while(!input(button));
}
void main()
{
while(TRUE)
{
i=0;
j=0;
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
printf("%d (%d,%d) ", A[j], i, j);
}
printf("\n");
}
waitpress();
}
}
Result:
0 (0,0) 0 (0,1) 0 (0,2) 1 (0,3) 1 (0,4) 0 (0,5) 0 (0,6) 0 (0,7)
1 (1,0)
0 (1,1) 0 (1,2) 0 (1,3) 0 (1,4) 0 (1,5) 0 (1,6) 0 (1,7)
1 (2,0) 0 (2,1)
0 (2,2) 0 (2,3) 1 (2,4) 1 (2,5) 0 (2,6) 0 (2,7)
0 (3,0) 0 (3,1) 0 (3,2
) 0 (3,3) 0 (3,4) 0 (3,5) 1 (3,6) 1 (3,7)
0 (4,0) 0 (4,1) 0 (4,2) 1 (4,
3) 1 (4,4) 0 (4,5) 0 (4,6) 0 (4,7)
1 (5,0) 0 (5,1) 1 (5,2) 0 (5,3) 0 (5
,4) 0 (5,5) 0 (5,6) 0 (5,7)
1 (6,0) 0 (6,1) 0 (6,2) 0 (6,3) 1 (6,4) 1 (
6,5) 0 (6,6) 0 (6,7)
0 (7,0) 0 (7,1) 0 (7,2) 0 (7,3) 0 (7,4) 0 (7,5) 1
(7,6) 1 (7,7)
Code:
#include <16F877A.h>
#include <stdlib.h>
#include <stdint.h>
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#define button PIN_A4
short A[8][8] =
{
{0,0,0,1,1,0,0,0}
{0,0,1,0,0,1,0,0}
{0,0,1,0,0,1,0,0}
{0,1,0,0,0,0,1,0}
{0,1,0,0,0,0,1,0}
{0,1,1,1,1,1,1,0}
{0,1,0,0,0,0,1,0}
{0,1,0,0,0,0,1,0}
};
int i,j;
void waitpress()
{
while(input(button));
while(!input(button));
}
void main()
{
while(TRUE)
{
i=0;
j=0;
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
printf("%d (%d,%d) ", A[j], i, j);
}
printf("\n");
}
waitpress();
}
}
Result:
0 (0,0) 0 (0,1) 0 (0,2) 1 (0,3) 1 (0,4) 0 (0,5) 0 (0,6) 0 (0,7)
1 (1,0)
0 (1,1) 0 (1,2) 0 (1,3) 0 (1,4) 0 (1,5) 0 (1,6) 0 (1,7)
1 (2,0) 0 (2,1)
0 (2,2) 0 (2,3) 1 (2,4) 1 (2,5) 0 (2,6) 0 (2,7)
0 (3,0) 0 (3,1) 0 (3,2
) 0 (3,3) 0 (3,4) 0 (3,5) 1 (3,6) 1 (3,7)
0 (4,0) 0 (4,1) 0 (4,2) 1 (4,
3) 1 (4,4) 0 (4,5) 0 (4,6) 0 (4,7)
1 (5,0) 0 (5,1) 1 (5,2) 0 (5,3) 0 (5
,4) 0 (5,5) 0 (5,6) 0 (5,7)
1 (6,0) 0 (6,1) 0 (6,2) 0 (6,3) 1 (6,4) 1 (
6,5) 0 (6,6) 0 (6,7)
0 (7,0) 0 (7,1) 0 (7,2) 0 (7,3) 0 (7,4) 0 (7,5) 1
(7,6) 1 (7,7)