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

pic 16f877A problem

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



Joined: 10 Apr 2010
Posts: 5

View user's profile Send private message

pic 16f877A problem
PostPosted: Sat Apr 10, 2010 5:32 am     Reply with quote

my program is not repeated. there is no loop


#include <16F877A.h>
#use delay(clock=4000000,restart_wdt)

void a()
{

output_b(0b00000000);
output_a(0b00000001);
delay_ms(1);
output_b(0b01110110);
output_a(0b00000010);
delay_ms(1);
output_b(0b01110110);
output_a(0b00000100);
delay_ms(1);
output_b(0b01110110);
output_a(0b00001000);
delay_ms(1);
output_b(0b00000000);
output_a(0b00100000);
delay_ms(1);

}
void b()
{

output_b(0b00000000);
output_a(0b00000001);
delay_ms(1);
output_b(0b00110110);
output_a(0b00000010);
delay_ms(1);
output_b(0b00110110);
output_a(0b00000100);
delay_ms(1);
output_b(0b00110110);
output_a(0b00001000);
delay_ms(1);
output_b(0b01001001);
output_a(0b00100000);
delay_ms(1);
}

void main()
{
int j;
while(1)
{

for(j=0;j<250;j++)
{
a() ;
}
for(j>250;j<500;j++)
{
b();
}
}
}

i need some help
ckielstra



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

View user's profile Send private message

PostPosted: Sat Apr 10, 2010 6:57 am     Reply with quote

When posting code use the 'code' button. This helps to preserve the layout of your program and makes for easier reading.

When you are having problems with your program always try to narrow down as much as possible. By removing as many parts as possible you will finally have a small (not working) program. This helps you to focus on where the real program is, instead of where you _think_ the program is.

What oscillator are you using? Crystal, clock generator, R-C?
Assuming you are using an external crystal change the start of your program to:
Code:
#include <16F877A.h>
#fuses XT, NOLVP, NOWDT
#use delay(clock=4000000)


A second problem is with variable 'j'. This is now declared as int but in the CCS compiler this equals to int8. An int8 has a maximum value of 255. You'll have to change it to an int16.

... and last:
Code:
for(j>250;j<500;j++)
This compiles but I'm not sure what code it will generate. Change to
Code:
for(j=250;j<500;j++)
ahmeddragonbleu



Joined: 10 Apr 2010
Posts: 5

View user's profile Send private message

PostPosted: Sat Apr 10, 2010 9:29 am     Reply with quote

Thanks a lot for your help.
Now my program is running very well.
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