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

12:00 minutes and seconds...

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



Joined: 19 Sep 2010
Posts: 5

View user's profile Send private message

12:00 minutes and seconds...
PostPosted: Sun Sep 19, 2010 2:17 am     Reply with quote

anybody can help me to fix this program,..


#include<16f877.h>
#fuses XT,NOLVP,NOWDT,PUT
#use delay (clock=1M)
#byte port_d=8
#byte port_a=5
#byte port_c=8
byte CONST LED_MAP[10]={0x3F,0x06,0x5b,0x4F,0x66,0x6D,0x7D,0x07,0X7F,0x6 F};

void display_number(int32 j)
{

output_c(LED_MAP[j/600%10]) ;
output_low(PIN_A4);
delay_ms(2);
output_high(PIN_A4);

output_c(LED_MAP[j/20%10]) ;
output_low(PIN_A3);
delay_ms(2);
output_high(PIN_A3);

output_c(LED_MAP[j/10%6]) ;
output_low(PIN_A2);
delay_ms(2);
output_high(PIN_A2);

output_c(LED_MAP[j%10]);
output_low(PIN_A1);
delay_ms(2);
output_high(PIN_A1);

}

void main()
{
int32 m,count=0;

while(TRUE)
{
for (m=0;m<=10;m++)
display_number(count);
count=(count==720)? 0:count+1;
}
}


i want to have a program like this [1][2]:[0][0]...

THE ic that i used is 16f877a...
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Sep 19, 2010 4:22 am     Reply with quote

When posting code please use the 'code' buttons to retain the layout of your code.

Quote:
THE ic that i used is 16f877a
Code:
#include<16f877.h>
You are using the wrong include file.

Code:
#byte port_d=8
#byte port_a=5
#byte port_c=8
These lines are not used. Remove them.

Code:
byte CONST LED_MAP[10]={0x3F,0x06,0x5b,0x4F,0x66,0x6D,0x7D,0x07,0X7F,0x6 F};
There is a space in between the last value '0x6_F'. Fix this.

Code:
output_high(PIN_A4);
Output A4 is Open Collector on most PIC processors. I don't know your circuit, but most likely you need a pull-up resistor or you will never output a high voltage.


Quote:
anybody can help me to fix this program,..
It helps if you describe your problem. What do you see your program is doing and how is this different from what you want it to do?
Always post your compiler version number.
sonic05



Joined: 19 Sep 2010
Posts: 5

View user's profile Send private message

^^
PostPosted: Sun Sep 19, 2010 7:40 am     Reply with quote

Code:

void main()
{
int32 m,count=0;

while(TRUE)
{
for (m=0;m<=0.01;m++)
display_number(count);
count=(count==86400)? 0:count+1;

output_d(0x02);
delay_ms(20);
output_d(0x04)
delay_ms(20);
output_d(0x08);
}

}

I have some problem on this part
Code:

output_d(0x02);
delay_ms(20);
output_d(0x04)
delay_ms(20);
output_d(0x08);

Why when I add this, the 7segment will on off. It is possible to add this when the display_number run? What should I do?

My plan is when the 7segment run the LED pattern will also run. Please help me...
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