Data Injecting using CodeWarrior

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Data Injecting using CodeWarrior

872 Views
AlonLahav
Contributor I

Hello,

 

I am using CodeWarrior as an emulator to an 8-bit microcontroller (GR16, HC08).

I wish to inject data from file on a certain point in the code. I wish to set up this file, and each time the Program Counter reaches a certain point, the CodeWarrior will read the next 8 bit data from the file into the Accumulator (or into the memory, or whatever).

 

In this mode, the real-time doesn't matter, and I use the microcontroller as kind of a simulator (that is connected to my other HW peripherals).

 

I know that some other emulators do have this ability, but I haven't found it in the CodeWarrior. Can it  do such a thing?

 

Thank you.

Labels (1)
0 Kudos
Reply
1 Reply

300 Views
stanish
NXP Employee
NXP Employee

Hello Alon Lahav,

 

You can try to use debugger script to accomplish this task. Debugger inject value when breakpoint is reached.

 

E.g.:

 

 *_HC08_PostLoad.cmd:

 

// After load the commands written below will be executed
BS fce     // set breakpoint at requested line
REPEAT     // modify values in loop
  GO       // Run (Debugger has to have disabled default BP at main)
  wait 10  // 1s delay, CPU must reach breakpoint within the delay specified here
 
//let's assume the CPU has reached BPT (Halted) within the delay otherwise it doesn't work
  A tst_ch=test[i]  // Copy custom char to the var. used in main loop
  A i=i+1           // increase another variable
UNTIL test[i] == 0x00 //continue untill all chars transferred

 main.c:

 


volatile char i=0,tst_ch=0;
volatile const char test[]="Hello!"; //data that should be "injected" when BP reached
volatile char out_buf[20];

void fce(void) //testing function where BP is set
{
  asm(NOP);
}

void main(void)
{
  for(;;) {
  out_buf[i]=tst_ch; // output buffer should include injected data at the end of script
  fce();             // the tst_ch is modified by the debugger here
} 

 

This script has some limitations: e.g. you have to define sufficient delay to ensure the breakpoint always occurs and CPU halts before variables are modified. (not sure if the debugger supports condition that tells if CPU runs or is halted).

Data that should be "injected" are in this example placed directly in the MCU memory. (linker entries section should include this variable/constant not to deadstrip it)

 

 

Stanish

 

 

 


 

0 Kudos
Reply