单片机常见问题解答
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
80C51 microcontrollers ?!
Q: I am trying to use an 89C51Rx+ microcontroller with external ram. The data is being read back just fine, but there is no activity on the data bus. Why?
A: The Philips Rx+ family of microcontrollers has 512 bytes of RAM (1024 for the RD+). The regular data pointer is 8 bit and can only handle up to 256 bytes. The remainder of the RAM is mapped as external memory, overriding any existing "real" external memory in that address range. In order to force the usage of real external memory, set bit "EXTRAM" (byte 8EH bit 1).
Q: I want to link the microcontroller to my PC using the serial port, but it doesn't work. What do I have to do?
A: The 8051-UART has several operating modes. Use mode 1 and set the correct speed using timer 0. The voltage levels also need to be adjusted. The microcontroller uses 0V/5V while the PC uses -12V/+12V. The most common way to do this is to use Maxim's MAX232.
Q: I need a development tool for a Philips microcontroller. Where do I find it?
A: Information on third party tools is available on the Microcontroller Support & Tools section of the Philips Semiconductors web page:
/mcu/tools/ This includes hotlinks to all tool web pages, including Philips development tools, which can be found on:
/.
Q: How do you use a target to Extend Emulator Power?
A: When debugging, it's important to be able to break execution when certain values appear in certain registers or memory locations. For example, when a variable is being trashed for no apparent reason, you might want to instruct your emulator to "run until location 30h = 80h." Some emulators let you specify an address where execution stops and a condition is checked. If the condition isn't met, execution restarts. Some let you pass through an address a number of times before checking. This powerful technique slows execution because the emulator halts execution and reads and compares the target-variable contents each time the address is struck. However, it's possible to check for a trashed variable at near-full emulation speed. All programs normally have a portion of code executed regularly and frequently (e.g., a timer interrupt routine). Just add this code fragment:
mov a , variable
cjne a, # 80h, temp_1
nop
temp_1:
If you place a breakpoint on nop and run the program, execution breaks the next time this code fragment executes after the variable is corrupted. By inspecting the prior instructions in the emulator's trace buffer, you can see where the location was overwritten.
Q: How do you debug Impure Code?
A: We generally think of microcontroller programs as collections of instruction codes. But, we (or our compiler) sometimes embed data in the code using look-up tables, constants, and strings. A problem arises if the assembly-language programmer or compiler follows a call to a routine with literal data to be used by that routine: