Docsity

MC9S12DP256 Flash Programming: Steps and Procedures - Prof. Bradley J. Bazuin, Lab Reports of Microcomputers

Toggle sidebar
bg1
Tutorial on MC9S12DP256 Flash Programming
Before programming the Flash area, the code must be compiled in ICC12 with
changes to the pseudo-vector address locations of the interrupts. The current
serial Boot Loader program that will be used in the programming the Flash
memory corrupts the D-BUG12. Therefore, after you have demonstrated your
code to the Lab Instructor the D-BUG12 Monitor program must be restored in the
Flash in order to return the board to its factory condition.
The example given in this Tutorial is based upon Timer 6 Interrupts. One should
consider the code lines as a template only that needs to be revised for any other
problem.
Steps to Program the Flash:
1. Open ICC12
2. Load your C code
Include the vectors_dp256.c file in your code. In order to do that copy that file
to your project folder from c:\icc\example.S12\vectors_dp256.c
#include “vectors_dp256.c”
In this file change the line: #pragma abs_address:0xFF80 to
#pragma abs_address:0xEF80 /* Changed for Flash programming*/
3. If your program uses interrupts then change the entry on the array assigned
to your particular interrupt as described below.
Example: A program uses TC 6 interrupts. The changes to be done to the vector
address array are as follows (the changes in the vectors_dp256.c and the main
code files are given below in bold face):
----------------------------------------------------------------------------------------------------------
extern void TC6_ISR(); // Å to be added before the array
#pragma abs_address:0xEF80
void (*interrupt_vectors[])(void) =
{
pf3
pf4
pf5

Partial preview of the text

Download MC9S12DP256 Flash Programming: Steps and Procedures - Prof. Bradley J. Bazuin and more Lab Reports Microcomputers in PDF only on Docsity!

Tutorial on MC9S12DP256 Flash Programming

Before programming the Flash area, the code must be compiled in ICC12 with changes to the pseudo-vector address locations of the interrupts. The current serial Boot Loader program that will be used in the programming the Flash memory corrupts the D-BUG12. Therefore, after you have demonstrated your code to the Lab Instructor the D-BUG12 Monitor program must be restored in the Flash in order to return the board to its factory condition. The example given in this Tutorial is based upon Timer 6 Interrupts. One should consider the code lines as a template only that needs to be revised for any other problem.

Steps to Program the Flash:

  1. Open ICC
  2. Load your C code Include the vectors_dp256.c file in your code. In order to do that copy that file to your project folder from c:\icc\example.S12\vectors_dp256.c #include “vectors_dp256.c” In this file change the line: #pragma abs_address:0xFF80 to #pragma abs_address:0xEF80 /* Changed for Flash programming*/
  3. If your program uses interrupts then change the entry on the array assigned to your particular interrupt as described below. Example: A program uses TC 6 interrupts. The changes to be done to the vector address array are as follows (the changes in the vectors_dp256.c and the main code files are given below in bold face):

extern void TC6_ISR(); // Å to be added before the array

#pragma abs_address:0xEF

void (*interrupt_vectors[])(void) = {

/* to cast a constant, say 0xb600, use (void ()())0xb / DUMMY_ENTRY, /Reserved $FF80/ DUMMY_ENTRY, /Reserved $FF82/ DUMMY_ENTRY, /Reserved $FF84/ DUMMY_ENTRY, /Reserved $FF86/ DUMMY_ENTRY, /Reserved $FF88/ DUMMY_ENTRY, /Reserved $FF8A/ DUMMY_ENTRY, /PWM Emergency Shutdown/ DUMMY_ENTRY, /Port P Interrupt/ DUMMY_ENTRY, /MSCAN 4 Transmit/ DUMMY_ENTRY, /MSCAN 4 Receive/ DUMMY_ENTRY, /MSCAN 4 Error/ DUMMY_ENTRY, /MSCAN 4 Wake-up/ DUMMY_ENTRY, /MSCAN 3 Transmit/ DUMMY_ENTRY, /MSCAN 3 Receive/ DUMMY_ENTRY, /MSCAN 3 Error/ DUMMY_ENTRY, /MSCAN 3 Wake-up/ DUMMY_ENTRY, /MSCAN 2 Transmit/ DUMMY_ENTRY, /MSCAN 2 Receive/ DUMMY_ENTRY, /MSCAN 2 Error/ DUMMY_ENTRY, /MSCAN 2 Wake-up/ DUMMY_ENTRY, /MSCAN 1 Transmit/ DUMMY_ENTRY, /MSCAN 1 Receive/ DUMMY_ENTRY, /MSCAN 1 Error/ DUMMY_ENTRY, /MSCAN 1 Wake-up/ DUMMY_ENTRY, /MSCAN 0 Transmit/ DUMMY_ENTRY, /MSCAN 0 Receive/ DUMMY_ENTRY, /MSCAN 0 Error/ DUMMY_ENTRY, /MSCAN 0 Wake-up/

DUMMY_ENTRY, /XIRQ/

DUMMY_ENTRY, /SWI/

DUMMY_ENTRY, /Unimplement Intruction Trap/ DUMMY_ENTRY, /COP failure reset/ DUMMY_ENTRY, /Clock monitor fail reset/ _start, /Reset/ }; #pragma end_abs_address


TC6_ISR is declared in the code as:

Void TC6_ISR (void) { //now clear the Timer 6 interrupt TFLG1 = 0x40; } By using the vector_dp256.c file one doesn’t need to declare the interrupt vector array in the code, which is the case while running the code in the RAM.

  1. Add the reference to the ISR in the vector_dp256.c file as described below. Ex: extern void TC6_ISR ();
  2. Before compiling the code using ICC12 add the following command in the ICC Select Project Æ Options Æ Compiler Æ Execute commands after a successful build. C:\icc\bin\SRecCVT –lp –m c0000 FFFFF 32 –o %pcvt.s19 %p.s This command converts the S19 file to the proper format to program the Flash correctly.
  1. In ICC12 select Project Æ Options Æ Target Æ Device Configuration Select: 9S12Dx256/Ax256/H
  2. Compile the code. The compilation will result in two S19 files: *.S19 and *cvt.S.

Programming of the Flash: First, make sure that your MC9S12DP256 board is disconnected from any external hardware (i.e., your breadboard).

  1. Open Hyper Terminal. The Settings should be the following:
  2. Set BAUD = 9600, 8, N, 1 Xon/Xoff = enabled
  3. Move jumper JB3 to the position PAD00: PAD01 = 1:
  4. Power up the Board. The Hyper Terminal will look like the one shown below: D-Bug12 Boot Loader v1.0.

a. Erase Flash b. Program Flash c. Set Baud Rate d. Erase EEPROM

  1. Choose “a” to erase
  2. Choose “b” to program The Unit is waiting for you to send a S-record (*CVT.S19), so send it. Use the option “send as text”.
  3. Once the Flash programming is complete disconnect the Board from the BDM Module and the power, and move jumper JB3 to the position PAD00: PAD01 = 0:
  4. Reconnect the power to the Board and press the Reset button. The micro controller should run your code.