On Sat, 2004-10-02 at 17:52, piclist@xargs.com wrote: > On Sun, 3 Oct 2004, Brent Brown wrote: > > > > void main(void) > > > { > > > TRISB = 0; > > > PORTB = 255; > > > } > > > > I think this is a fairly common hurdle for people to overcome when first > > learning C. Your two lines of code will get executed and then the processor > > will wander off into never never land because you haven't told it what to do > > next. > > I agree that falling off the end of main() is not a good idea, but the > code won't wander off into uninitialzed code space. Code generated by > the Hi-Tech compilers jumps back to the beginning after the closing > brace of main(). Are you absolutely certain of that? Does HiTech put a "goto" at the end brace? I would be very surprised and disturbed if they did. Remember, that if execution DOES go into "never never" land, and all of that place is uninitialized, the PIC will simply see 3ff as the op code. Since that is an invalid op code it will treat it as a NOP and increment the PC. Eventually the PC will wrap and hit address 0, which of course is the first instruction of your program, which will "rerun" your program, giving the ILLUSION that the program "restarted". ----------------------------- Herbert's PIC Stuff: http://repatch.dyndns.org:8383/pic_stuff/ _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist