We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi everyone..... Hope u r fine....... I have a problem in the following code
ORG 00H BACK:MOV A,#55H MOV P1,A ACALL DELAY MOV A,#0AAH MOV P1,A ACALL DELAY SJMP BACK DELAY: MOV R3,#70 H2:MOV R4,#254 H1:DJNZ R4,H1 DJNZ R3,H2 RET END
Now if i see the output in port P1 I see that P1:0xAA then 0X55 then 0XAA then 0x55 (repeat continuously......)toggling Pins:0xAA then 0X55 then 0XAA then 0x55 (repeat continuously......)toggling Now if i modify my program by just replacing port P1 by port P0 in all lines and now if i see output in port P0 i see that.. P1:0xAA then 0X55 then 0XAA then 0X55 (repeat continuously......)toggling pins:there is no change or toggling Why is it so?????? Why is there no toggling in output window of port p0 under pins: pins:No change P0:toggling plz help me out......
HI ... HERE IS MY MODIFED CODE.. My cpu is AT89C51 and i just test my program i am not burning it...
ORG 00H BACK:MOV A,#55H MOV P0,A ACALL DELAY MOV A,#0AAH MOV P0,A ACALL DELAY SJMP BACK DELAY: MOV R3,#70 H2:MOV R4,#254 H1:DJNZ R4,H1 DJNZ R3,H2 RET END
Now if i see the output in port P1 now if i see output in port P0 i see that.. P1:0xAA then 0X55 then 0XAA then 0X55 (repeat continuously......)toggling pins:there is no change or toggling Why is it so?????? Why is there no toggling in output window of port p0 under pins: pins:No change P0:toggling While if u see output in case of port P1 we see toggling in both cases pins:toggling P1:toggling plz help me out......
just a guess: are you aware that P0 does not have pull-ups?
Erik
I am able to duplicate your problem. I modified your code to toggle all four ports and selected a generic 80C51 device. All Port pins toggle except P0 after the first output. P0 will set to the first value and then it will no longer display. On a simple eval board the pins do toggle. It would appear there is a bug in the simulator for P0. Suggest that you contact Keil tech support and reference this thread.
ORG 00H BACK:MOV A,#55H MOV P0,A MOV P1,A MOV P2,A MOV P3,A ACALL DELAY MOV A,#0AAH MOV P0,A MOV P1,A MOV P2,A MOV P3,A ACALL DELAY SJMP BACK DELAY: MOV R3,#70 H2:MOV R4,#254 H1:DJNZ R4,H1 DJNZ R3,H2 RET
END Erik; Do you have additional suggestions? Bradford
Just re-read Eril's post. Of course he is right about P0 as an open drain output that requires pull-up in the real hardware. I don't know if Keil is trying to emulate this in the simulator. Bradford
Erik; Do you have additional suggestions?
Yes, accept the fact that no simulator is perfect. it can never be.
were I not "ICE rich" I would consider using the simulator to debug non-I/O functions
Thank you sir.... But can u tell mw what does the pins and P1 under port P1 shows...... I mean if we open any port to see the output we have two thing.. P0: pins: I want to ask whats the difference between these two? What effect does the pull up hav on port P0.. plz help
Thank you sir...... But can u clarify me whats the difference between port P0 and pins of P0 I maen when we see the output of my program in port P0 we have two things: P0: pins: Whats does both of these shows Whats the differnce between two? What effect does pull up have on pins: plz carify
read "the bible! it will answer all your questions.
here are the links to "the bible" Chapter 1 - 80C51 Family Architecture: www.nxp.com/.../80C51_FAM_ARCH_1.pdf
Chapter 2 - 80C51 Family Programmer’s Guide and Instruction Set: www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Chapter 3 - 80C51 Family Hardware Description: www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf
Stop using SMS (Stupid Monkey ***). Stupid Monkey *** has no place in a professional forum, if you want to contine using it, go somewhere where you can join other bungling amateurs.
At this time I suggest that you spend a little time on the basic 8051 hardware structure. These document links will give you a good introduction to the 8051 devices. Links taken from Erik's reply to thread 6922.
Chapter 1 www.semiconductors.philips.com/.../ various/80C51_FAM_ARCH_1.pdf
chapter 2 www.semiconductors.philips.com/.../ various/80C51_FAM_PROG_GUIDE_1.pdf
chapter 3 www.semiconductors.philips.com/.../ various/80C51_FAM_HARDWARE_1.pdf
Also, go to http://www.8052.com for on-line tutorials. That said the Keil Debugger simulates both the port latch and the the I/O pins. The port latch stores the last value written to the port by the internal CPU firmware. There are a number of 8051 instructions that read the current port value before modifying the port value. These are called read-modify-write instructions. The are built into the firmware. The programmer has no control over this action. Notice the write operation. On a read operation, the firmware reads the actual pin value. So the Keil Debugger simulates the actual 'pins' with the pin dialog and the port latch with the port dialog.
Erik types faster than me. What happened to my links? I guess my fumble fingers hit the enter key too often.
PO is the register you read and write from in software. P0 pins are the little metal things that stick out of the chip. P1,2, and 3 can drive the output High and Low. P0 can not drive the pin high only low. This is for "Plain" 8052 chips. Newer version may be different.
Just because you set the port bits to high, that doesn't mean that the processor actually manages to hold them high. If the port pin is connected to the output of another chip, that other chip may drive the signal low.
Hence you can set one value for the port, and then look at the port pin register to check what state the pins really did get.
So the port can be both an input and an output and the same time.
This is very clearly described if you do take the time to read the supplied links. If you decide to not read the links (or similar links/books), you will never be able to use the processor even close to what it can do.
There is no way people on forums will spend the time to try to duplicate all that information so the only way you can grow is if you spend time learning.