Code Example For Stop2 Mode ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Code Example For Stop2 Mode ?

1,136 Views
m2s
Contributor I
Hy, I'm wondering if someone have an example on how they save all register value into ram and get them back into the register when returning from Stop2 mode.
 
Is theyre a faster way than simply copy the information regsiter by regsiter ?
 
best regards.
Labels (1)
0 Kudos
2 Replies

298 Views
Ake
Contributor II
The fastest way for saving the registers would be something like this
 
pshh ;save h 2
pshx ;save x 2
psha ;save a 2
tpa ;get a copy of the status register 1
psha; and save it 2
tsx; get stack pointer to hx 2
sthx savedSP ;save the stack pointer 4
So it would take 2+2+2+1+2+2+4 = 15 clock cycles or 0.75 uS on a 20 Mhz 9S08.
 
In the savedSP word the SP should be saved so when the CPU is powered up, it first checks the savedSP word. If it is < 0xffff, the saved data can be restored. If = 0xffff, no data has been saved.
 
 
Regards,
Ake
 
 
 
0 Kudos

298 Views
m2s
Contributor I
Thank's
 
To that I need to add the instructions to save all I/O regsiter to.
0 Kudos