This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MCU Timing not responding!

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.

  • But the delays do not respond as per programmed.
    does the rest "respond as per programmed" ?
    delay loop or T0/T1/T2?

  • Everything else responds. As in some programmes work and some don't. LCD text display doesn't work but LCD text rotation works but with shortened delay. If I set delay for LED's to be 1s, it becomes as fast as 2.3 seconds. Serial Communication perfectly working.

  • how you handle delay by function or by timer ?

  • I do it by function. Using a nested loop.

  • 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"...