Downloading and Running a Program from RAM

I have an application that boots up from Flash, and then downloads an application into RAM. The RAM program is downloaded from the .h86 file and then executed by a far jump. Most all of the downloaded RAM code runs fine, but a few of the functions behave oddly. Are there any system initialization operations that should be performed before jumping into the RAM code?

Parents
  • Are there any system initialization operations that should be performed before jumping into the RAM code?

    Yes, there are, but not many. The microcontroller's external bus interface must be set up already since the code in RAM runs. First of all, if the application in RAM uses interrupts, you have to properly set up the interrupt vector table. Secondly, code generated by the C166 compiler assumes that the system stack and the user stack are set up. Thirdly, for near data access, the DPPx registers have to hold the right values. Stacks and DPPs (as well as other things like global variable initialisation) are taken care of by the code in START167.A66. You have to take care ot the interrupt vector table yourself.
    If you jump directly to main in your code in RAM, you bypass the initialisation code in START167.A66. The initialisation code of the boot program in flash can be good enough for the code in RAM to run properly, but not necessarily.
    Needless to say that the application to be run in RAM has to be built for the address range it is going to run in. Normally it cannot be shifted in memory and be expected to run properly.

    - mike

Reply
  • Are there any system initialization operations that should be performed before jumping into the RAM code?

    Yes, there are, but not many. The microcontroller's external bus interface must be set up already since the code in RAM runs. First of all, if the application in RAM uses interrupts, you have to properly set up the interrupt vector table. Secondly, code generated by the C166 compiler assumes that the system stack and the user stack are set up. Thirdly, for near data access, the DPPx registers have to hold the right values. Stacks and DPPs (as well as other things like global variable initialisation) are taken care of by the code in START167.A66. You have to take care ot the interrupt vector table yourself.
    If you jump directly to main in your code in RAM, you bypass the initialisation code in START167.A66. The initialisation code of the boot program in flash can be good enough for the code in RAM to run properly, but not necessarily.
    Needless to say that the application to be run in RAM has to be built for the address range it is going to run in. Normally it cannot be shifted in memory and be expected to run properly.

    - mike

Children
More questions in this forum