CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

18f & max7219 help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chico_pic



Joined: 21 Sep 2012
Posts: 10

View user's profile Send private message

18f & max7219 help
PostPosted: Sun Aug 18, 2013 7:55 pm     Reply with quote

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.
    }
   
    }   
 
   
}
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Aug 18, 2013 8:05 pm     Reply with quote

Quote:
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


I assume you mean you have two MAX7219s connected on the SPI bus
and only one works?

It appears you are trying to use and expand on someone else's code without understanding how it all works.

How are you handling the Load /CS (chip select)? How/where is it connected?
Look at the Load/CS pin in the datasheet timing diagram and how it works.
_________________
Google and Forum Search are some of your best tools!!!!
chico_pic



Joined: 21 Sep 2012
Posts: 10

View user's profile Send private message

PostPosted: Sun Aug 18, 2013 9:03 pm     Reply with quote

I have two ci connected.

I understand I have customized the code to understand it even more and I want it modified to work with 2 MAX7219.
chico_pic



Joined: 21 Sep 2012
Posts: 10

View user's profile Send private message

PostPosted: Sun Aug 18, 2013 9:43 pm     Reply with quote

purchase a LED matrix in a garage sale for 1 dollar
the LED matrix is composed 128x7 LED
and has 8 MAX7219 and 18F252

in isis I have connected 2 Cl only when you really are 8 CI

IMG1
http://www.4shared.com/photo/UsvOp55A/img.html
IMG2
http://www.4shared.com/photo/SSZZaXmx/20130818_221329.html
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group