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 support@ccsinfo.com

Subroutine to display a counter on max7221

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
The Puma



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

View user's profile Send private message

Subroutine to display a counter on max7221
PostPosted: Mon Jan 16, 2006 3:54 pm     Reply with quote

I need a subroutine in CCS-C for driving a MAX7221.
The standard initialize routines works already thanks sebdey

This subroutine must past a value ( from 0 to 9999999) and display this on a 8 digit seven segment display

Can someone help me how to built this?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 16, 2006 4:29 pm     Reply with quote

It seems like you gave up on the other code in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=25672

You need to learn how to read error messages from the compiler
and fix syntax errors or other coding problems.

To fix that code, you just need to add these two lines at the top:
Code:
#case
#define MAX7221_CS  PIN_C0


The reason for using #case is because he has defined the word
"intensity" in two places, and the compiler doesn't like that.
Code:
#define   INTENSITY      0x0A

void setDisplayIntensity(int intensity)

So it's obvious to me that he must be using the #case directive
to prevent compiler errors.

The chip select (MAX7221_CS) obviously must be defined as some
PIC i/o pin. He didn't provide a definition, so you must choose a pin,
and then put it into a #define statement, as shown above. I just
chose Pin C0 because it seemed convenient.
The Puma



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

View user's profile Send private message

PostPosted: Mon Jan 16, 2006 4:38 pm     Reply with quote

I have this code working,
but i need a subroutine thats counts ket we say from 1 to 999999
and past that value to a subroutine to drive the MAX7221

How can i send this value to this routine

void setDisplayDigit(int digit, int value)
{
if(digit<8)
{
output_low(MAX7221_CS);
delay_cycles(4);

spi_write(digit+1);
spi_write(value);

output_high(MAX7221_CS);
}
}


There must an translation to drive digit 1 with the correct value, digit 2 with the correct value and so on
How to realize that?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 16, 2006 5:07 pm     Reply with quote

Look at the SplitDigit() function in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=24866
It will extract the digits and put them in an array.
Then you can use a for() loop to index into the array
and get each digit and send it to the MAX7221 with
the setDisplayDigit(int digit, int value) function.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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