You are here: Home DOCUMENTATION NanoCore12 NanoCore12 User Manual - 4 WRITING SOFTWARE

Technological Arts Inc.

Your Shopping Cart

Your Cart is currently empty.

NanoCore12 User Manual - 4 WRITING SOFTWARE

Article Index
NanoCore12 User Manual
1 INTRODUCTION
2 GETTING STARTED
3 HARDWARE DESIGN FEATURES
4 WRITING SOFTWARE
All Pages

4  WRITING SOFTWARE

 4.1    IMPACT OF THE SERIAL MONTIOR

When you are working without a BDM pod, the Serial Monitor is the only method available to load and erase flash.  Fortunately, it is in a protected block of flash, so there’s no way to accidentally erase it.  The Serial Monitor has two modes, controlled by switch SW2:  Run and Load.  The monitor determines the mode immediately following reset by checking the position of switch SW2.  When working with the monitor program in place, there are a few points to be noted:  

1) while the user vectors are implemented by the monitor at 0xF780 to 0xF7FF, you don’t really have to worry about it, because the monitor program will automatically adjust them when your s-record is loaded.  Just make sure to always include a reset vector in your program, as well as any interrupt vectors your program will use.

2) the monitor relocates RAM to the address range 0x3800 to 0x4000 from the default location after MCU reset of 0x0000 to 0x07FF.  This is done so there is no overlap with the register block.  (On NanoCore12MAXC128, RAM is remapped to the range 0x3000 to 0x4000).  If you launch your program via uBug12, the RAM has already been relocated, but if you switch to Run and launch your program by resetting the MCU, the RAM is at its default location unless you explicitly relocated it at the beginning of your program.  This point is very important, because if your program has any variables, calls any subroutines, or contains any interrupt service routines, it's not going to work if you assumed the relocated RAM and stack pointer addresses the monitor uses.

3) the monitor program enables the phase-locked loop (PLL), so the module runs at 24Mhz instead of the MCU’s default startup speed of 4Mhz.  If you launch your program via uBug12, the bus speed has already been boosted by the monitor to 24MHz, but if you switch to Run and launch your program by resetting the MCU, the bus is at its default speed of 4 MHz unless you explicitly enabled the PLL to boost the bus speed to 24 MHz at the beginning of your program.  This point is very important, because anything based on timing will be running at 1/6th the speed (or 6 times the delay) without the PLL active.  If you're using the SCI, it's not going to work if you assumed the higher bus speed the monitor uses.

4) your code must clear the CCR I-Bit  (e.g. via the CLI  instruction in assembler or the INTR_ON() directive in ICC) if you want to run your program under monitor control via uBug12 for debugging purposes

5) the SCI cannot be used by the your program when in Load mode, since it is dedicated to the monitor program.

6) COP cannot be disabled in Load mode.

4.2    USING A BDM POD

If you have a BDM pod, you can erase the resident monitor program completely.  This will free up all the MCU resources for your program (most importantly, the SCI), but you won't be able to use uBug12 again unless you load the serial monitor back into flash.