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