| View previous topic :: View next topic |
| Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 15, 2007 2:00 pm |
|
|
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:
In the MAX7221.H file, it has this line:
| Quote: | | #include "drv_spi.h" |
So then look at this file:
Extract this file from the .zip:
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:
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
|
|
Posted: Mon Oct 15, 2007 2:09 pm |
|
|
@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
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
|
|
Posted: Sat Oct 27, 2007 3:11 pm |
|
|
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
|
|
Posted: Mon Oct 29, 2007 5:16 pm |
|
|
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
|
|
Posted: Tue Oct 30, 2007 9:30 am |
|
|
@PCM programmer,
Ok thanks |
|
 |
|