The user program can be written according to the normal program, but the following points should be noted
The program is written to a fixed location and cannot overlap with the location of the BootLoader program. Otherwise, the program may not be able to run after being downloaded by the BootLoader. The corresponding operations are also performed in prm.
If interrupts are needed, the interrupt vector should be offset;
Offset the starting vector;
Write address alignment.
1. The BootLoader program is written to a fixed location:
ROM_C000 = READ_ONLY DATA_NEAR IBCC_NEAR 0xC000 TO 0xEFDF;
Make sure it does not overlap with the address starting from F000 of the BootLoader;
INTO ROM_C000/*, ROM_4000*/;
2. Offset the interrupt vector. When an interrupt occurs, push the current PC position into the stack, and then find the current interrupt function through the interrupt vector. One interrupt vector cannot correspond to two interrupt function addresses.
To offset the interrupt vector, we must first define the following interrupt vector table, where unused interrupts are represented by Unimplemented_ISR, and then set the interrupt offset register IVBR = 0x7F in the main function.
3. The offset of the starting vector. The starting vector is the address that the PC pointer points to at the beginning of the program. The default value is FFFE. If it is offset, the program cannot be run directly and can only be run in the BootLoader. Therefore, when we use the host computer to send the S19 file of the program, we need to change the FFFE in the FFFE line to the address we need.
4. When using the host computer to transfer S19 files, some addresses are not aligned with the FLASH write operation address, such as FFFE, so we need to fill the data of FFF0~FFFD addresses with FF;
#pragma CODE_SEG NON_BANKED
interrupt void Unimplemented_ISR(void)
{
asm BGND; //software breakpoint
}
#pragma CODE_SEG DEFAULT
typedef void (*near tIsrFunc)(void);
const tIsrFunc VectorTable[] @0xEF10 =
{
Unimplemented_ISR, // Vector base + 0x10 Spurious interrupt
Unimplemented_ISR, // Vector base + 0x12 System Call Interrupt (SYS)
Unimplemented_ISR, // Vector base + 0x14 Reserved
Unimplemented_ISR, // Vector base + 0x16 Reserved
Unimplemented_ISR, // Vector base + 0x18 Reserved
Unimplemented_ISR, // Vector base + 0x1A Reserved
Unimplemented_ISR, // Vector base + 0x1C Reserved
Unimplemented_ISR, // Vector base + 0x1E Reserved
Unimplemented_ISR, // Vector base + 0x20 Reserved
Unimplemented_ISR, // Vector base + 0x22 Reserved
Unimplemented_ISR, // Vector base + 0x24 Reserved
Unimplemented_ISR, // Vector base + 0x26 Reserved
Unimplemented_ISR, // Vector base + 0x28 Reserved
Unimplemented_ISR, // Vector base + 0x2A Reserved
Unimplemented_ISR, // Vector base + 0x2C Reserved
Unimplemented_ISR, // Vector base + 0x2E Reserved
Unimplemented_ISR, // Vector base + 0x30 Reserved
Unimplemented_ISR, // Vector base + 0x32 Reserved
Unimplemented_ISR, // Vector base + 0x34 Reserved
Unimplemented_ISR, // Vector base + 0x36 Reserved
Unimplemented_ISR, // Vector base + 0x38 Reserved
Unimplemented_ISR, // Vector base + 0x3A Reserved
Unimplemented_ISR, // Vector base + 0x3C Reserved
Unimplemented_ISR, // Vector base + 0x3E ATD0 Compare Interrupt
Unimplemented_ISR, // Vector base + 0x40 Reserved
Unimplemented_ISR, // Vector base + 0x42 Reserved
Unimplemented_ISR, // Vector base + 0x44 Reserved
Unimplemented_ISR, // Vector base + 0x46 Reserved
Unimplemented_ISR, // Vector base + 0x48 Reserved
Unimplemented_ISR, // Vector base + 0x4A Reserved
Unimplemented_ISR, // Vector base + 0x4C Reserved
Unimplemented_ISR, // Vector base + 0x4E Reserved
Unimplemented_ISR, // Vector base + 0x50 Reserved
Unimplemented_ISR, // Vector base + 0x52 Reserved
Unimplemented_ISR, // Vector base + 0x54 Reserved
Unimplemented_ISR, // Vector base + 0x56 Reserved
Unimplemented_ISR, // Vector base + 0x58 Reserved
Unimplemented_ISR, // Vector base + 0x5A Reserved
Unimplemented_ISR, // Vector base + 0x5C Reserved
Unimplemented_ISR, // Vector base + 0x5E Reserved
Unimplemented_ISR, // Vector base + 0x60 Reserved
Unimplemented_ISR, // Vector base + 0x62 Reserved
Unimplemented_ISR, // Vector base + 0x64 Reserved
Unimplemented_ISR, // Vector base + 0x66 Reserved
Unimplemented_ISR, // Vector base + 0x68 Reserved
Unimplemented_ISR, // Vector base + 0x6A Reserved
Unimplemented_ISR, // Vector base + 0x6C Reserved
Unimplemented_ISR, // Vector base + 0x6E Reserved
Unimplemented_ISR, // Vector base + 0x70 Reserved
Unimplemented_ISR, // Vector base + 0x72 Reserved
Unimplemented_ISR, // Vector base + 0x74 Periodic interrupt timer channel 3
Unimplemented_ISR, // Vector base + 0x76 Periodic interrupt timer channel 2
Unimplemented_ISR, // Vector base + 0x78 Periodic interrupt timer channel 1
PIT0_ISR, // Vector base + 0x7A Periodic interrupt timer channel 0
Unimplemented_ISR, // Vector base + 0x7C High Temperature Interrupt (HTI)
Unimplemented_ISR, // Vector base + 0x7E Autonomous periodical interrupt (API)
Unimplemented_ISR, // Vector base + 0x80 Low-voltage interrupt (LVI)
Unimplemented_ISR, // Vector base + 0x82 Reserved
Unimplemented_ISR, // Vector base + 0x84 Reserved
Unimplemented_ISR, // Vector base + 0x86 Reserved
Unimplemented_ISR, // Vector base + 0x88 Reserved
Unimplemented_ISR, // Vector base + 0x8A Reserved
Unimplemented_ISR, // Vector base + 0x8C PWM emergency shutdown
Unimplemented_ISR, // Vector base + 0x8E Port P Interrupt
Unimplemented_ISR, // Vector base + 0x90 Reserved
Unimplemented_ISR, // Vector base + 0x92 Reserved
Unimplemented_ISR, // Vector base + 0x94 Reserved
Unimplemented_ISR, // Vector base + 0x96 Reserved
Unimplemented_ISR, // Vector base + 0x98 Reserved
Unimplemented_ISR, // Vector base + 0x9A Reserved
Unimplemented_ISR, // Vector base + 0x9C Reserved
Unimplemented_ISR, // Vector base + 0x9E Reserved
Unimplemented_ISR, // Vector base + 0xA0 Reserved
Unimplemented_ISR, // Vector base + 0xA2 Reserved
Unimplemented_ISR, // Vector base + 0xA4 Reserved
Unimplemented_ISR, // Vector base + 0xA6 Reserved
Unimplemented_ISR, // Vector base + 0xA8 Reserved
Unimplemented_ISR, // Vector base + 0xAA Reserved
Unimplemented_ISR, // Vector base + 0xAC Reserved
Unimplemented_ISR, // Vector base + 0xAE Reserved
Unimplemented_ISR, // Vector base + 0xB0 CAN0 transmit
Unimplemented_ISR, // Vector base + 0xB2 CAN0 receive
Unimplemented_ISR, // Vector base + 0xB4 CAN0 errors
Unimplemented_ISR, // Vector base + 0xB6 CAN0 wake-up
Unimplemented_ISR, // Vector base + 0xB8 FLASH
Unimplemented_ISR, // Vector base + 0xBA FLASH Fault Detect
Unimplemented_ISR, // Vector base + 0xBC Reserved
Unimplemented_ISR, // Vector base + 0xBE Reserved
Unimplemented_ISR, // Vector base + 0xC0 Reserved
Unimplemented_ISR, // Vector base + 0xC2 Reserved
Unimplemented_ISR, // Vector base + 0xC4 CRG self-clock mode
Unimplemented_ISR, // Vector base + 0xC6 CRG PLL lock
Unimplemented_ISR, // Vector base + 0xC8 Reserved
Unimplemented_ISR, // Vector base + 0xCA Reserved
Unimplemented_ISR, // Vector base + 0xCC Port H
Unimplemented_ISR, // Vector base + 0xCE Port J
Unimplemented_ISR, // Vector base + 0xD0 Reserved
Unimplemented_ISR, // Vector base + 0xD2 ATD0
Unimplemented_ISR, // Vector base + 0xD4 SCI1
Unimplemented_ISR, // Vector base + 0xD6 SCI0
Unimplemented_ISR, // Vector base + 0xD8 SPI0
Unimplemented_ISR, // Vector base + 0xDA TIM Pulse accumulator input edge
Unimplemented_ISR, // Vector base + 0xDC TIM Pulse accumulator A overflow
Unimplemented_ISR, // Vector base + 0xDE TIM timer overflow
Unimplemented_ISR, // Vector base + 0xE0 TIM timer channel 7
Unimplemented_ISR, // Vector base + 0xE2 TIM timer channel 6
Unimplemented_ISR, // Vector base + 0xE4 TIM timer channel 5
Unimplemented_ISR, // Vector base + 0xE6 TIM timer channel 4
Unimplemented_ISR, // Vector base + 0xE8 TIM timer channel 3
Unimplemented_ISR, // Vector base + 0xEA TIM timer channel 2
Unimplemented_ISR, // Vector base + 0xEC TIM timer channel 1
Unimplemented_ISR, // Vector base + 0xEE TIM timer channel 0
RTI_ISR, // Vector base + 0xF0 Real time interrupt
Unimplemented_ISR, // Vector base + 0xF2 IRQ
Unimplemented_ISR, // Vector base + 0xF4 XIRQ
Unimplemented_ISR, // Vector base + 0xF6 SWI
Unimplemented_ISR // Vector base + 0xF8 Unimplemented instruction trap
};
Previous article:mc9s12 c language, Freescale mc9s12 prm file detailed explanation 2
Next article:MC9S12XS128MAL Bootloader(1)
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Registration for the prize live broadcast is open | TOF (Time of Flight) technology introduction and product application
- Zero-knowledge open source sharing-the use of ESP8266WIFI module
- STM32CUBEMX generates EWARM V8 project, but cannot open the project
- System performance indicators of single-phase sine wave inverter
- PADS PCB board partial circuit replication
- Phantom Power in Audio Equipment
- View Circuit-CSA and System
- Delayed season planning and preparation progress
- Free Download | 2018 ADI Solution Selection Compilation
- Today's live broadcast: Rochester Electronics Semiconductor Full Lifecycle Solutions Help You Meet the Challenges of Supply Chain Disruptions and Component Discontinuations