??? 06/29/05 18:39 Read: times |
#96223 - A couple more little things Responding to: ???'s previous message |
Jan Waclawek said:
Very good question, this confuses probably many newbies. You can find the answers in the "bible", but needs really thorough reading... Agreed. It took me quite a while to really get this straight. There are some subtle "gotchas" involved. The "alternative" input functions usually don't collide, as they need setting some SFR bits to become active (and after reset these bits are reset too) - e.g. enable interrupt in IE register for external interrupt pins, enable receiving setting the REN bit in SCON for Rx pin, enabling the counter function for timer/counter input pins in TCON etc.
For alternative output functions on Port3 pins, you can consider them as simply wire-ORed with the simple output (as if there are two open collector outputs tied together). So you don't need to enable anything special to use the alternate function. If you leave the output of the port to be 1, you can use the alternative function; if you set it to 0, it will remain 0 regardless of the alternative function. The implication here is that, for example, in the case of /RD and /WR, the mere presence of MOVX instructions in the executed code will cause these two signals to be asserted as appropriate. That's not really a problem, but it is something to be aware of. Ports 0 and 2 and their alternative function as address/data bus is different. During external memory cycle (regardless of if it is a data or program memory, so this applies for MOVX, MOVC and program fetches), Port2 is set to the higher address (strongly both to 0 and 1), and after the external memory cycle ends, it resumes the original content (if no other external memory cycle follows). For Port0, at the beginning of the memory cycle, the lower address is latched into the output latch and is output during ALE is active - so essentially, external memory accesses destroy Port0 content.
Jan Waclawek Yes, that sounds right for MOVC and MOVX instructions involving DPTR. But it is also possible to do MOVX with 8-bit indirect addressing (e.g., MOVX A,@R0). In this case, during the external memory access, port 2 is left in whatever state it was prior to the external memory access. If you require a particular value on port 2 (for a high address byte) when using this type of addressing, you must manually set port 2 prior to the move. --Sasha Jevtic |
Topic | Author | Date |
function of 8051 pins | 01/01/70 00:00 | |
double functions | 01/01/70 00:00 | |
a requirement | 01/01/70 00:00 | |
Yeah... and it's really big too! :) | 01/01/70 00:00 | |
port0 | 01/01/70 00:00 | |
thanks | 01/01/70 00:00 | |
do not SHOUT | 01/01/70 00:00 | |
A couple more little things | 01/01/70 00:00 | |
PORT2 during MOVX @Ri | 01/01/70 00:00 | |
which should'nt be a problem | 01/01/70 00:00 | |
Same thought, almost same time | 01/01/70 00:00 | |
Port 2 in memory access | 01/01/70 00:00 | |
double function of SBUF | 01/01/70 00:00 | |
thank you jan waclawek![]() | 01/01/70 00:00 |