Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Mikro c pro delay not working

Status
Not open for further replies.

thannara123

Advanced Member level 5
Advanced Member level 5
Joined
Jan 7, 2010
Messages
1,601
Helped
122
Reputation
244
Reaction score
116
Trophy points
1,353
Activity points
10,611
hai experts in mikroc pro
i write a led blinking program
but the delay not working
my programm is follows
void main()
{
TRISB=0;
PORTB=1;
delay_ms(1000);
PORTB=0;
}
it didnt blink .it full time in ON condition

i reversed
the program that is
PORTB=0:
delay_ms(1000);
PORTB=1
}
at this time the LED will not ON

please help me thanks
 

hai experts in mikroc pro
i write a led blinking program
but the delay not working
my programm is follows
void main()
{
TRISB=0;
PORTB=1;
delay_ms(1000);
PORTB=0;
}
it didnt blink .it full time in ON condition

i reversed
the program that is
PORTB=0:
delay_ms(1000);
PORTB=1
}
at this time the LED will not ON

please help me thanks

plz................. use loop.....
without loop this is not working properly
 

void main()
{
TRISB=0;
while(1)
{

PORTB=0;
delay_ms(1000);
PORTB=1;
}
}
sir i used the loop as follows above but not woking please help me
thanks for reply
 

void main()
{
TRISB=0;
while(1)
{

PORTB=0;
delay_ms(1000);
PORTB=1;
}
}
sir i used the loop as follows above but not woking please help me
thanks for reply

your problem is that after switching portB to 1, the next instruction is switching portb to zero! :-D

you should add one more delay after PORTB=1, something like this:

Code:
while(1){

PORTB=0;
delay_ms(1000);
PORTB=255;
delay_ms(1000);

}

it will be 1sec ON and 1sec OFF for the whole PORTB
 

yes like axxe say
as without this delay the transition from 0 to 1 on portb will happen but you will not be able to see it as it is very fast.
as in your code the MC will do 1 sec OFF and xx usec (xx depend on your OSC ) ON then it convert to OFF and so on.
 

void main() {
while(1){
TRISB=0;
PORTB=0;
delay_ms(1000);
PORTB=255;
delay_ms(1000);

}


}
I USED this but no luck
not working nothing happened
may it my mikroc has any problem ?
i direct copped from tutorials and paste int mikroc pro but nothing
pleas what i do
 

Show us the remainder of the program. You show nothing that tells the compiler which processor you are using, the clock speed or configuration settings. You should at least include a header to associate the port names with their addresses. Are you saying it fails in simulation or in a real circuit, if the latter, show us the schematic, it could be an electrical problem.

Brian.
 

i used firstly the pic16f877a clock with clock speed 4Mhz & 8 Mhz
latter i tested on 16f887 with both 4mhz and 8 mhz
nothing
the mikroc pro has a sample led blinking (with first startup ) for 16f887
i build it's hex and and simulated nothing get

Sir i use only simulation .
simulator used Proteus ,oshonsoft's pic simulato & real pic simulator

what i do ?
please help me
thanking you
 

just try this:

void main() {
trisb=0;
portb=0;
while(1){
portb=0b11111111;
delay_ms(50);
portb=0;
delay_ms(50);
}
}
=====================================
also your code will work good but if you use any simulation software you should reduce delay time as simulators has a different calculations with our time.
as u see i just take your code and reduce the time
 
void main() {
while(1){
TRISB=0;
PORTB=0;
delay_ms(1000);
PORTB=255;
delay_ms(1000);

}


}
I USED this but no luck
not working nothing happened
may it my mikroc has any problem ?
i direct copped from tutorials and paste int mikroc pro but nothing
pleas what i do

Hi thannara this code works fine for me. i compiled using 4.15v.
May be its the problem in ur proteus or this compiler.
 
thanks i changed the simulator
and changed the speed
now its ok
thanks again
 

i used firstly the pic16f877a clock with clock speed 4Mhz & 8 Mhz
latter i tested on 16f887 with both 4mhz and 8 mhz
nothing
the mikroc pro has a sample led blinking (with first startup ) for 16f887
i build it's hex and and simulated nothing get

Sir i use only simulation .
simulator used Proteus ,oshonsoft's pic simulato & real pic simulator

what i do ?
please help me
thanking you

The most important piece of information in your response is the fact that
you are using the mikro-c example code and that doesnt work.

I know for certain that the code works therefore your issue is not originally a code issue.

If you are using a simulator it is either not configured correctly or cannot work
with mikro-c code. That is the first thing to check.

If you are using electronics then as betwixt says - post your circuit.

The example code you posted is incomplete so can't be diagnosed as someone mentioned. The processor speed is not the issue - your full code is. Chips need to be set up before being programmed. That is what is missing and being asked for.

Reading between the lines you are not familiar with the simulator or C code
or how to set them up - so start with basics.

Stick to the mikro-c example we all know does work - and post the setup for the specific simulator or dev board you are using and your full code.

Someone familiar with your specific simulator will then probably be able to spot
something you missed fairly easily.

But my best guess at this point is you havn't initialised the chip. You also need (as betwixt said) to name the chip - they all initialise slightly differently.

jack
 
I repeat what I wrote earlier: Tell us the rest of the program. There is nothing wrong with the code you show so the problem is somewhere else. The code you show will not work on it's own so please show the header and include files you are using.

Brian.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top