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.
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?
I thought I'd make his code even more perfect.
Faulty controller or faulty programmer?
I know which one I would say.
#include <REGX51.H> void wait (void) { ; } 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 */ } } } }
All the nice words used in this thread shows the level some people manages...
Anyway - don't do for loops. Bind your delays to timer hardware. Unless you don't want it to work...
Bind your delays to timer hardware. Unless you don't want it to work... OR write them in assembler
it is the correct action of a good optimizer to say that this code
for (i = 0; i < 30000; i++) { /* Delay for 10000 Counts */ wait (); /* call wait function */ }
affect nothing and thus should be ignored
Try setting the optimization level to zero
also what happens when main() ends?
Erik
you state above: // 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 Indicating you are using a monitor (it took a while for you to tell us that)
and have this
for (j=0x01; j< 0x80; j<<=1) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */ P3 = j; /* Output to LED Port */
since the UART uses P3.0 and P3.1 something stinks
All right Thank you very much everybody. And a bigger thanks to some 'WISE' people who found time to criticize people telling them 'idiot' and whatever. It shows your level hahah!! Take care and don't mess anyone else's thread this way. You never know who is there on the other side. So do not display your foolishness on-line at least.
The code is pretty awful and his posting techniques severely lacking, but falling off 'main' (surprisingly) isn't an issue here. He's got the:
while (1)
The code is pretty awful and his posting techniques severely lacking, which kind of hides that
falling off 'main' (surprisingly) isn't an issue here