Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

REQ: CCS C Code sample to drive a MAX7219 with 7 digits

Status
Not open for further replies.

The Puma

Full Member level 2
Joined
Apr 4, 2002
Messages
134
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
895
max7219 ccs

I need a CCS C code example to drive with a MAX7219 7 segment digits
ans this code counts from 1 to 9999999

Maybe someone has a library for the MAX7219
 

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);
}
 

max7219 code

Hi
I need the same codes for bascom AVR , I've tried several times to drive this IC but no result .
thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top