max7219 bascom
#include <16F877.h>
#fuses NOWDT,NOPROTECT
#use delay(clock=4000000)
#include <max7221.c>
char bir=0;
char on=0;
void say()
{
bir++;
if(bir>9)
{
bir=0;
on++;
delay_ms(10);
}
if(on>9)
{
on=0;
bir=0;
}
}
main()
{
//set_tris_c(0x00);
init_7221();
delay_ms(100);
while(1){
{/*
send_16bit(1,1);
send_16bit(2,2);
send_16bit(3,3);
send_16bit(4,4);
send_16bit(5,5);
send_16bit(6,6);
send_16bit(7,7);
send_16bit(8,0x0b);*/
say();
send_16bit(1,on);
send_16bit(2,bir);
}
}
}
Added after 40 seconds:
#ifndef __MAX7221_H
#define __MAX7221_H
#define da pin_c5
#define cs pin_c0
#define clk pin_c3
#endif
void send_16bit(byte address,byte data)
{
byte i;
#bit carry=0x03.0;
carry=0;
output_low(cs);
for(i=0;i<8;i++)
{
if((address & 0b10000000)==0)
output_low(da);
else
output_high(da);
rotate_left(&address,1);
output_high(clk);
delay_us(50);
output_low(clk);
delay_us(50);
}
for(i=0;i<8;i++)
{
if((data & 0b10000000)==0)
output_low(da);
else
output_high(da);
rotate_left(&data,1);
output_high(clk);
delay_us(50);
output_low(clk);
delay_us(50);
}
output_high(cs);
}
char time;
void init_7221()
{
time=10;
send_16bit(0x09,0xff); //decode
delay_us(time);
send_16bit(0x0a,0x0f); //intensity
delay_us(time);
send_16bit(0x0b,0x01); //scan limit
delay_us(time);
send_16bit(0x0c,0x01); //shutdown
delay_us(time);
send_16bit(0x0f,0x00); //display
delay_us(time);
}