in C51, if I use overlap optimize, my project have problem.( routine R1 changed routine R2's auto variable). if I do not use overlap optimize. the problem gone. Is this Keil's problem? I guess so. How dose Keil do overlap optimize?
_rotate_motor() function will be block for 300ms. so, R2 get to run This line sounds like you're using some sort of RTOS to switch between your tasks. If you have two different tasks that can preempt each other, then you need to manually adjust the overlay tree to be sure each task has its own "stack". Each independent thread needs to be an independent root of an overlay tree. See chapter 9 of the linker manual. Turning overlaying off entirely will of course avoid the problem, at the cost of using up a lot of memory.