|
|
View previous topic :: View next topic |
Author |
Message |
nicenoise
Joined: 10 May 2004 Posts: 17 Location: barcelona
|
pic12f675 with max7221!!!!! |
Posted: Wed Oct 26, 2005 3:01 pm |
|
|
hello,
i'm trying to connect a pic12f675 with a max7221 led driver.
Exactly i'm using the "b32cdm module" but this is a max7221 with a led matrix of 64 leds in 8x8 distribution. This is my code and the library. I try with version of compiler v3.212 and 3.190 with the same result. I use the internal clock of the pic and the pins A0,A1 and A4 to control the display.
Code: |
#include <12F675.h>
#fuses XT,NOWDT,NOPROTECT,NOMCLR,NOBROWNOUT,INTRC_IO
#use delay(clock=4000000)
#ROM 0x3ff = {0x349C}
#byte ADCON0 = 0x1f
#byte ADRESL = 0x9E
#byte CMCON = 0X19
#byte ANSEL = 0x9F
#include "max7219.c"
main()
{
int i,j;
CMCON = 0x07; // apaga los comparadores
ANSEL = 0x00; // GPIO pins en modo digital
setup_comparator(NC_NC_NC_NC);
setup_adc_ports(NO_ANALOGS);
setup_timer_1(T1_DISABLED);
output_low(CLK);
delay_us(1);
output_high(LOAD);
display_init(); // Inicializa el display
while(TRUE)
{
for(i=1;i<=8;i++){
for(j=0;j<=9;j++){
display(i,j);
delay_ms(200);
}
}
}
}
|
and this is the library "max7219.c"
Code: |
#define DATA PIN_A0
#define LOAD PIN_A1
#define CLK PIN_A4
void display(char adresse,char wert)
{
char x;
output_low(LOAD);
for (x=0;x<4;x++)
{
output_low(DATA); // METE 4 CEROS EN DATA, 4 PRIMEROS BITS
output_high(CLK);
delay_us(1);
output_low(CLK);
delay_us(1);
}
for (x=4;x>0;x--)
{
if (bit_test(adresse,x-1)) output_high(DATA);
else output_low(DATA);
output_high(CLK);
delay_us(1);
output_low(CLK);
delay_us(1);
}
for (x=8;x>0;x--)
{
if (bit_test(wert,x-1)) output_high(DATA);
else output_low(DATA);
output_high(CLK);
delay_us(1);
output_low(CLK);
delay_us(1);
}
output_high(LOAD);
}
void display_init()
{
display(0x0B,0x07); // scan limit - 8 columnas
display(0x0C,0x01); // Shutdown - normal mode
display(0x09,0x00); // decode mode = 0
display(0x0A,0x07); // intensity
//display(0x0F,0x00); // test
}
|
I think is ok...
Any sugestions???
Thanks
Alex |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 26, 2005 4:14 pm |
|
|
Quote: | I think is ok...
Any sugestions??? |
Are you searching for sample code to compare to your code ?
Someone objected to me telling them to use Google, but I did
anyway, searching for: MAX7221 int #define
Here's a sample driver:
http://seniord.ee.iastate.edu/dec0212/code/max7221.h
Here's their project page.
http://seniord.ee.iastate.edu/dec0212/final.report/
One other comment. You've got both XT and INTRC_IO fuses.
If you want to use the internal oscillator, get rid of the XT fuse.
#fuses XT,NOWDT,NOPROTECT,NOMCLR,NOBROWNOUT,INTRC_IO |
|
|
|
|
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
|