chico_pic
Joined: 21 Sep 2012 Posts: 10
|
18f & max7219 help |
Posted: Sun Aug 18, 2013 7:55 pm |
|
|
hi people
I am creating a project with a PIC18F252 and two two MAX7219 LED matrix.
I managed to display characters in the max1 but the second I did not succeed.
anyone know how??
someone help me?
Code: | #include <18F252.h>
#fuses NOWDT,NOPROTECT,NOLVP,NODEBUG
#use delay(clock=18000000)
#use spi( DI=pin_c3,DO=pin_c1,clk=pin_c2,bits=16,load_active=1,load=pin_c0,idle=1)
int address, data, adqnum, digit[4]; //
int direcc,dato,Column,Start_Byte,x ;
int16 packetmax, result; //
unsigned int8 Alphabet[156]={
0x7f, 0x88, 0x88, 0x88, 0x88, 0x7f, // A
0xff, 0x91, 0x91, 0x91, 0x91, 0x6e, // B
0x7e, 0x81, 0x81, 0x81, 0x81, 0x42, // C
0xff, 0x81, 0x81, 0x81, 0x81, 0x7e, // D
0x81, 0xff, 0x91, 0x91, 0x91, 0x91, // E
0x81, 0xff, 0x91, 0x90, 0x90, 0x80, // F
0x7e, 0x81, 0x81, 0x89, 0x89, 0x4e, // G
0xff, 0x10, 0x10, 0x10, 0x10, 0xff, // H
0x00, 0x81, 0xff, 0xff, 0x81, 0x00, // I
0x06, 0x01, 0x81, 0xfe, 0x80, 0x00, // J
0x81, 0xff, 0x99, 0x24, 0xc3, 0x81, // K
0x81, 0xff, 0x81, 0x01, 0x01, 0x03, // L
0xff, 0x60, 0x18, 0x18, 0x60, 0xff, // M
0xff, 0x60, 0x10, 0x08, 0x06, 0xff, // N
0x7e, 0x81, 0x81, 0x81, 0x81, 0x7e, // O
0x81, 0xff, 0x89, 0x88, 0x88, 0x70, // P
0x7e, 0x81, 0x85, 0x89, 0x87, 0x7e, // Q
0xff, 0x98, 0x98, 0x94, 0x93, 0x61, // R
0x62, 0x91, 0x91, 0x91, 0x91, 0x4e, // S
0xc0, 0x81, 0xff, 0xff, 0x81, 0xc0, // T
0xfe, 0x01, 0x01, 0x01, 0x01, 0xfe, // U
0xfc, 0x02, 0x01, 0x01, 0x02, 0xfc, // V
0xff, 0x02, 0x04, 0x04, 0x02, 0xff, // W
0xc3, 0x24, 0x18, 0x18, 0x24, 0xc3, // X
0xc0, 0x20, 0x1f, 0x1f, 0x20, 0xc0, // Y
0xc3, 0x85, 0x89, 0x91, 0xa1, 0xc3, // Z
};
void maxsend(){ //routine for send information to the max
packetmax=make16(direcc,dato); //make a 16 bit variable direcc byte high, dato byte low
spi_xfer(packetmax); //transfer using spi software
}
void Clear_Matrix(void) //routine for clean screen
{
for(direcc=1;direcc<9;direcc++)
{
dato=0x00;
maxsend( );
}}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// maybe here i can configure for scanning left to right //
void maxsetup(){ //setup max //
direcc=0x09, dato=0x00, maxsend(); // BCD mode for digit decoding //
direcc=0x0a, dato=0x0f, maxsend(); // Segment luminosity intensity //
direcc=0x0b, dato=0x07, maxsend(); // Display refresh //
direcc=0x0C, dato=0x01, maxsend(); // Turn on the display //
direcc=0x0f, dato=0xFf, maxsend(); // No test //
} //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Write_Char(char myChar) // send the date
{
//Clear_Matrix(); // Clear the display first.
// The next line defines our byte, from which to start the array.
Start_Byte = (myChar - 65) * 6; // 65 represents the letter "A" in ASCII code.
// We are using only columns from 2 through 7 for displaying the character.
for(direcc=2;direcc<8;direcc++) // columns 2 to 7
{
maxsend( ); // i send the date columns & through
Alphabet[Start_Byte++]; // add through
dato = Alphabet[Start_Byte]; //
}
}
void main(void) {
delay_ms(1000); // whait, whait,whait. take easy!! loololo
maxsetup(); // configure the max
Delay_ms(1000); // one more time whait
while (TRUE)
{
for(x=65;x<=90;x++) // Increment with 1, from 65 until 90.(A to Z)
{
Write_Char(x);
Delay_ms(1000); // This is our delay, between two consecutive character.
}
}
} |
|
|