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.

Trouble with Keil programming

Status
Not open for further replies.

Jack// ani

Advanced Member level 3
Advanced Member level 3
Joined
Dec 2, 2004
Messages
757
Helped
107
Reputation
222
Reaction score
58
Trophy points
1,308
Activity points
5,006
Hi all,

What could be wrong with this one, not working at all. And please tell me how to calculate time delay.

#include <AT89S8252.h>

void wait (void)
{
;
}

void main( void )
{
unsigned int i;

P1 = 0;

while(1)
{
P1=1;
for (i=0;i<10000;i++)
{
wait();
}
P1=0;
}
}


Thanks
 

your wait() function is not detailed. there may be some problem. And if it is blank, I see a ; in it. Otherwise it seems ok!
 

Trouble with ke*il programming

I got the Keil codes form somewhere and modified it a little. Wait function was carrying ; there also! If it is wrong then please give me the correct code? What about time delay?
 

Trouble with ke*il programming

Why not use the timer for delay? I recommend my solution in actual project. I use a timer to compute the delay. set the controller to power saving mode. if the timer decrease to 0, trigger the timer interrupt serving code, which is a return. and return to the next instruction of the main program.
 

Your code is OK.

The problem (and the solution), I think is:

1º) You write P1 = 1;
2º) You waste some time (for loop)
3º) You write P1 = 0;
4º) Repeat 1-3: You write P1 = 1:

Step 3 (P1 = 0) is very short because immediately you write P1=1. You must include another for loop after step 3.

Regards, svicent
 

You dont need wait func at all, inthis case I aways use this:

for (i=0;i<10000;i++)
{
}

Program counting i from 0 to 10000, so you made wait func, witout wait func.

Should you consider to use interrupts for waiting (in serious aplications), couse your program will stop in that point untill i rich 10000, so everything else will be stoped for that time.

Mr.Cube
 

Trouble with ke*il programming

Thanks for suggestion, still this doesn’t solves my problem. My hardware is working fine, and problem seems to be on the software side. Here is the hex which I get after compilation

:01002B0022B2
:10000300E4F590759001E4FFFE12002B0FBF000191
:0C0013000EBE27F5BF10F2E4F59080E768
:0300000002001FDC
:0C001F00787FE4F6D8FD7581070200032D
:00000001FF

Whats the problem?
 

hai
Hope you have added a wait after clearing the port to 0 also.

Instead of HEX check the disassembly window in keil and see how the code is compiled and see if programe is ok in simulator.
How the output is now?
Picstudent
 

Picstudent get the point,


you have just a few cycles where are P1=0, so its always 1.

If you have osciloscope you can see that, and we are all blind, just add one more wait after P1=0.


Mr.Cube
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top