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 CCS Technical Support

Max7221 and dot matrix displays
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 15, 2007 2:00 pm     Reply with quote

Look at other MAX7221 drivers that are available on the internet.
There is one here.
http://www.picos18.com/Download/PIC18/
Look at the code for the latest version:
Quote:
max7221_v1_02.zip


In the MAX7221.H file, it has this line:
Quote:
#include "drv_spi.h"


So then look at this file:
Quote:
SPI_v1_02.zip

Extract this file from the .zip:
Quote:
drv_spi.c


Then look at this routine in that file:
Quote:
void SPI_config(void)
{
TRISCbits.TRISC3 = 0; // Clock as output
TRISCbits.TRISC5 = 0; // SDO as output

// Init SPI bus
SSPSTAT = 0x3F; // power on state
SSPCON1 = 0x00; // power on state

SSPCON1bits.CKP = 0;
SSPCON1 |= 0x00; // Master Mode Fosc/4
SSPSTATbits.SMP = 0;
SSPSTATbits.CKE = 1;
SSPCON1bits.SSPEN = 1; // SPI enable

/* Init the different FIFO */
SPI_current_message = NULL;
SPI_list_head = NULL;
SPI_list_head_rcv = NULL;
}

Notice that it sets the SPI mode bits as:
Quote:

CKP = 0
CKE = 1

Then see the chart posted by ckielstra here:
http://www.ccsinfo.com/forum/viewtopic.php?t=32040&start=5
It shows that those settings are SPI mode 0,0.
So, somebody else also believes that the MAX7221 mode is 0,0
which is what the data sheet says it is.

If you think it's really some other mode, then just go do it.
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Oct 15, 2007 2:09 pm     Reply with quote

@PCM Programmer:

Thx for your work, but the cascades max7221 (ten parts) did't work correctly with the L_TO_H setting for some reason.

I did't no Mad
Which to H_TO_L it works well.

On the other side which one MAX7221 (connected to eight 7 segment displays) the L_TO_H work well
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Oct 27, 2007 3:11 pm     Reply with quote

How can i display the charaters of the font on led matrix 1

the fontdata go from 0x20 (space) to 0x7f (DEL)
Must i change itoa function to somewhat else??

This code counts from 0 to 1000

if i use this
strcpy(text_buffer,"!");
then the ! char wil display on the led matrix
But i would that all characted of the fonts will be displayed on the matrix display in loop from 32 to 127

Code:
   max7221_init();
   max7221_blank_dot_matrix_display();
   for(j=0;j<=MAX_NUMBER_TO_DISPLAY;j++) {
      strcpy(text_buffer,itoa(j,MAX_TEXT_BUFFER_SIZE,text_buffer));
      max7221_fill_dot_matrix_buffer(text_buffer);
      max7221_display_dot_matrix_buffer();
      delay_ms(100);
   }

Code:
void max7221_fill_dot_matrix_buffer(char *buffer) {
   int8 msg_length,index;
   char *msg_ptr,currentchar;
   
   memset(dot_matrix_buffer,0x00,MAX_DOT_MATRIX_BUFFER_SIZE);
   msg_length=strlen(buffer);
   msg_ptr=&dot_matrix_buffer[0];
   for(index=0;index<msg_length;index++) {
      currentchar=buffer[msg_length-index-1];
      memcpy(msg_ptr,font5x7[currentchar-0x20],MAX_FONT_SIZE);
      msg_ptr+=MAX_FONT_SIZE;
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 29, 2007 5:16 pm     Reply with quote

You want to convert an ascii character into a string and put the string
into a buffer. One way to do this is with sprintf(). See the manual.
Quote:

for(j = '!'; j <= 0x7F; j++)
{
sprintf(text_buffer, "%c", j);
max7221_fill_dot_matrix_buffer(text_buffer);
max7221_display_dot_matrix_buffer();
delay_ms(100);
}
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Oct 30, 2007 9:30 am     Reply with quote

@PCM programmer,

Ok thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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