The 8051 micro-controller(P89V51RD2FN) that I have been using is configured on a 11.0592 Mhz crystal. But the delays do not respond as per programmed. The programs are perfectly written and there is no issue in the code. Is my controller faulty? How to check that? Please provide some troubleshoot tips and tricks. Thank you very much.
I do it by function. Using a nested loop.
try to do it with timer
no issue in the code
Of course you would say that, but it way more likely that you have got an issue with the code.
Maybe if you were as clever as me you would be able to say such a thing. But you are not me and therefore all you have done is make an obviously fictitious statement.
Almost certainly the source of your troubles!
www.8052.com/.../162556
Dude I have tested the code in a simulator and works perfectly on other controllers! Hahahah do not underestimate others!
"I do it by function. Using a nested loop."
So your initial post were wrong then, when you wrote: "The programs are perfectly written and there is no issue in the code."
Delays using loops will always have issues.
If you write the loop in assembler, you can make sure the loop have a minimum time. But it could be longer depending on interrupts while the loop is executing.
If you write the loop in C, then you make assumptions about the compilers optimizations and code generation that you are not allowed to make. There are no page in the C language standard or in the C manual for your compiler that contains a contract between you and the compiler vendor that x iterations of a specific loop will/must take a specific amount of time.
Any change of compiler version, optimization level or even use of global variables (remember that the C51 compiler converts local variables into reused global variables) can make a huge difference in loop delay times. The compiler can even totally throw away the loop delay if it doesn't see any real work performed by the loop.
Anyway - whenever you post and ask for help you need to ask yourself the following: Does this post really contain all information needed for people to help you?
Your post didn't. You did say your code was perfectly written, which was wrong. But you did not show us how you created your delays, which was critical information to be able to help you with your problems.
"Hahahah do not underestimate others!"
Very interesting statement, since it actually implies that _you_ just underestimated other posters because you still made assumptions about your code being good and correct even if your code is making assumptions you aren't allowed to make.
For loops were not added to the C language to create timing-critical delays. They were implemented to let a program be able to do someting multiple times. If time is important, then you need to map your code to some actual hardware that is ticking at a specific speed. Suck as a timer. Or such as the transmit delay time of the UART (assuming you don't use hardware handshake) or the transfer delay of a SPI peripherial or similar. But something that counts out time based on the processor crystal and where the processor documentation contains a binding contract promising a specific timing delay based on specific configurations used.
Yes - the documentation about how the timers of the processor works really is that contract telling you how to get a translation from crystal frequency into internal program delay. No such thing exists for a for loop. And no - the simulator is not there to be assumed to represent a contract. The simulator may not care if the processor consumes 1, 2, 3, 4, or 12 clock cycles for a single instruction. The simulator represents an approximation of the processor. Not the real deal.
Things that works in a simulator is never representing a proof that the same code works on the real hardware. Just that the simulation is likely to let you catch lots of coding errors. But not all. The simulator don't care about exact timing needs of the display. The simulator don't cares about bouncing input switches.
LOL!
Try searching the forum for all the, "My code works perfectly (sic) in the simulator, but not on real hardware" posts...
Lol everyone please calm down I am just a beginner. A 3rd year Engineering student. Just trying to learn something. Do not pounce on me I am not a professional. My question is How to check if a controller is working or not. Mine is not responding properly!
how can I am just a beginner state The programs are perfectly written
having worked vith youngsters I have heard the above many times when it was incorrect.
questioms delay loop in C or asm optimization level show your delay code
Erik
Mine is not responding properly!
The most likely fix for that is to correct your code. Stop whimpering like an idiot. You must face the fact that you have made a mistake. Grow up a bit and just do it.
I have already given more of my precious time than you really deserve and will not discuss further. Goodbye.
Sorry Mr. Bill Gates! Carry on with your busy schedule. I didn't ask you to nag on my problem. If I was really an idiot why would have given me attention. Probably you are a bigger one!! Get yourself a psychiatrist. Pathetic people!!
"Mine is not responding properly!"
That is almost certainly due to your code rather than a faulty chip.
However, if you really think that your chip is faulty, your should take it to an appropriate member of staff (ask your teacher if unsure) who will have the facilities to test it for you; eg, by loading a known-working application, or by loading your application into a known-working chip.
"Do not pounce on me I am not a professional"
So don't set yourself up by saying stuff like, "my code is perfect"...
The most sensible reply that I found in this forum! thanks a lot... actually I have tried it on another chip and the code works perfectly. However in this faulty chip the same codes work but the time delays are altered. So I was emphasizing upon how to test the hardware!
"However in this faulty chip"
How many times are you going to repeat this idiotic statement? Will you ever realize your code is at fault here?
Take this *** and tell me the fault man!! /* BLINKY.C - LED Flasher for the Keil MCBx51 Evaluation Board with 80C51 device*/
#include <REGX51.H>
// When you have enabled the option Stop Program Execution with Serial // Interrupt, the Monitor-51 uses the serial interrupt of the UART. // It is therefore required to reserve the memory locations for the interrupt // vector. You can do this by adding one of the following code lines:
// char code reserve [3] _at_ 0x23; // when using on-chip UART for communication // char code reserve [3] _at_ 0x3; // when using off-chip UART for communication
void wait (void) { /* wait function */ ; /* only to delay for LED flashes */ }
void main (void) { unsigned int i; /* Delay var */ unsigned char j; /* LED var */
while (1) { /* Loop forever */ for (j=0x01; j< 0x80; j<<=1) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */ P3 = j; /* Output to LED Port */ for (i = 0; i < 30000; i++) { /* Delay for 10000 Counts */ wait (); /* call wait function */ } }
for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 */ P3 = j; /* Output to LED Port */ for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */ wait (); /* call wait function */ } } } }
Take this *** and tell me the fault man!!
Look fool. If you describe your code as *** and you post it in the same *** manner then your expectation of anything apart from ridicule just shows you for what you are ... an idiot.
Ever thought of attempting a simpler course? Like basic cooking for morons?