From: Joris v. d. S. <vd...@pu...> - 2000-11-11 18:55:26
|
(My ISP bounced back my previous attempt to send this mail. My apologies if this posting should end up twice on the list. -- Joris) At 18:15 10-11-00 -0800, you wrote: > I have already added a __page_no__ variable > using the scheme you described will be executed at the entry > of a function with uses xstack. Woeps. I have just studied the data-sheets for the AT89C52, and found out I was wrong. The example I gave earlier won't work: mov dph,_stack_page movx a,@dptr ; WRONG! Won't permanently latch P2! mov r0,_spx mov a,r2 movx @r0,a ; push r2 on external stack When executing a 'movx @r0,a' or 'movx a,@r0' instruction, the microcontroller will *not* multiplex port P2 with the MSB of the address generator! Therefore port P2 will have the last value latched into its internal buffer. However, 'movx a,@dptr' will not latch the buffer, it will only multiplex temporarily with the address generator. Therefore, we should latch the page *explicitly* into P2: mov P2,_stack_page ; this will *really* latch the page mov r0,_spx mov a,r2 movx @r0,a ; push r2 on external stack Also, I said '_stack_page' was stored in 'idata', but that had to be 'data' of course. Sorry, it had been over 36 hours since I had some sleep. Doing much better today ;-) > using the scheme you described will be executed at the entry > of a function with uses xstack. I don't think that is necessary. You only need to do this once in the startup-code. I am not aware of any boards using a multiplexed P2 / external ram. Therefore, I think it is safe to assume that programs using external ram almost certainly won't modify P2 themselves. Kind regards, Joris van der Sande vd...@pu... |