|Shopping Cart Checkout Shipping Cost Download Website|
|You are here: 8051 Tools Development Board Example Code Auto Startup|
Automatic Start-Up Of Your ApplicationEventually, you will want to make your own application run automatically when you boot the board, instead of PAULMON2's menus. To accomplish this, you must do two things:
When you reboot the board, the autostart code will run automatically. It will configure the baud rate, set up the interrupt vectors, and then jump to your code. The board will be permanently dedicated to run your application, unless you use the flash erase jumper to restore it to the original, erased condition.
Default Settings: Code at 0x8000, Baud Rate is 115200 Bits/secIf the default settings are ok, then you can use the autostart example code without any modification. Just download the autostart.hex file (zip format).
This code resides in the memory from 0xF600 to 0xF7FF (the last 512 bytes of the flash), so your application must not use that memory. Of course, the full source code is available if you need that memory, or the default settings are not correct for your application.
Configuring Your Code's Build LocationIf you are using SDCC, just change the --code-loc parameter in the Makefile, so that your application is built to reside entirely inside the flash rom, and rebuild the code (often times "make clean" or deleting the .hex file is needed). Usually 0x8000 is the best choice, so that your code begins at the beginning of the flash rom and has the maximum amount of space available. It should look like this:
If you are using AS31, you will need to place a ".org" directive at the beginning of your code. For example:
Before downloading the autostart.hex file, try using PAULMON2's "J" (Jump) command to jump to your code at 0x8000. If that works and you are ready to permanently dedicate the board to automatically running your application, then you are ready to download the autostart.hex file.
Erasing The FlashAfter you have downloaded this "autostart.hex" file, your board will be permanently dedicated to running your own application code and PAULMON2's interactive menus will no longer be available.
If you wish to return to PAULMON2's menus, you must use the flash erase jumper to erase the flash rom. Short the upper two pins together and keep them shorted while you press the RESET button. When the board resets, the flash rom will be erased and you will be returned to the PAULMON2 prompt, where you may further develop your application or use the board for a new purpose.
Customizing Baud Rate SetupWhen you boot the board, a portion of the autostart code inserts some bytes into memory to configure the baud rate that PAULMON2 will use to initialize the serial port. Several common baud rates are defined in the code, so you can simply uncomment one if your baud rate in listed:
If you need a different baud rate, you must compute the value for "baud_const", using this formula:
baud_const = 256 - (115200 / baud_rate)
Customizing Application StartupThe default setting is to configured for your application code to begin at 0x8000, which is the beginning of the flash memory. The autostart code is located from 0xF600 to 0xF7FF, the end of the flash memory. However, it is easy to change these by editing constants in the code:
Of course, the complete source code is provided, so you can edit the code to perform any customized startup you need. The normal code simply writes seven LJMPs into RAM in the 0x2000, so that the interrupts will jump to your interrupt code in the flash rom, and then jumps to your program's starting location.
For example, if the additional LJMP interrupt latency is not acceptable, you could modify the code to instead copy your interrupt handler to the RAM. Or perhaps you are not using interrupts and you want to avoid writing to the RAM during a reboot, in which case you could simply delete that section.
Download The Autostart Code