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 CCS Technical Support

Trying to learn CCS : 7-segment

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







Trying to learn CCS : 7-segment
PostPosted: Mon Feb 09, 2004 6:09 pm     Reply with quote

This is following the sample code from CCS to drive a 7-segment display.
My question is, why doesn't using #use fast_io() and set_tris_x() work?

#use_fast_io(B)
#use fast_io(C)

set_tris_b(0x00);
set_tris_c(0xFC);


I tried putting a bit of delay between switching of specific bits but to no avail.


This is the code that works pefectly by standard_io. Using fast_io I noticed that RB<0:7> and RC<0:1> could never go HIGH.


#include <16f877.h>
#fuses HS, NOLVP, NOWDT, PUT
#use delay(clock=20000000)

byte CONST LED_MAP[10] = {0x3f, 0x06, 0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67};

void display_number(int n)
{
output_b(LED_MAP[n/10]);
output_low(PIN_C0);
delay_ms(2);
output_high(PIN_C0);
output_b(LED_MAP[n%10]);
output_low(PIN_C1);
delay_ms(2);
output_high(PIN_C1);
}

void main()
{
int count=1, i;

while(1)
{
for(i=0; i<=200; i++)
{
display_number(count);
}
count = (count==99) ? 1: count+1;

}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 10, 2004 12:44 pm     Reply with quote

Post the code that doesn't work. Post it as a complete program.
(ie, the same way as the working code, showing #fuse statement, etc.).
New_Convert
Guest







PostPosted: Tue Feb 10, 2004 3:49 pm     Reply with quote

I got it working. Thank you.
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