|
|
View previous topic :: View next topic |
Author |
Message |
New_Convert Guest
|
Trying to learn CCS : 7-segment |
Posted: Mon Feb 09, 2004 6:09 pm |
|
|
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
|
|
Posted: Tue Feb 10, 2004 12:44 pm |
|
|
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
|
|
Posted: Tue Feb 10, 2004 3:49 pm |
|
|
I got it working. Thank you. |
|
|
|
|
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
|