In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote: Ron, I think it is good practice not to rely on any default register states after a reset. Therefore, in every application I write for the SX, I first initialize the port output registers, like MOV RA, #RA_INIT, etc. Next, I configure other port settings, like level, pull-up, etc., and finally configure the TRIS registers, i.e. define which pins are inputs and outputs. This way, you can be sure that the SX has the same port state after each reset. I found out that some registers are even initialized differently when you reset the SX using the Debugger, or do a reset on a stand-alone system. For example, the FSR register is cleared on a debugger reset where it contains abitrary data when a stand-alone SX is reset. This once almost drove me nuts: To clear all RAM locations, I copied and pasted the following code from another program: ClearRAM sb fsr.4 setb fsr.3 clr ind ijnz fsr, ClearRAM This worked fine when testing the application with the debugger but sometimes, the program ran into "Nirwana" when executed on a stand-alone SX. Why? Because I forgot to copy and paste the first very important instruction: clr fsr With the debugger, FSR was always automatically cleared but not on a stand-alone system. So in this case, some RAM locations were not cleared, and other parts of the code, relying on this did nit work as expected. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=152406#m152703 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)