0

My environment...

  • PIC24
  • MpLab (V.8.80)
  • ICD 3

I have a byte that I want to watch, to see which routines are reading and which ones are actually writing, and when it happens

I can only set a breakpoint on

  • when the byte is written, or
  • when it is read

Does anyone know a way that I can set a breakpoint on either access ? i.e., I would like to watch what is written, AND what is read, in what order, by which instruction, in which routine.

All I have are a PICkit 3 and this ICD-3. It's a dual processor system where the two chips are communicating via some wires connected (ultimately, via Peripheral Pin Select) to their respective UARTs

I have never used, or touched, or even seen, a REAL Ice. Would that allow me to do this ? i.e., any bus memory access.

This is what MpLab lets me do right now with ICD-3 enter image description here

User.1
  • 2,562
  • 3
  • 33
  • 40
  • Can't you set two breakpoints, one for each of "read" and "write"? – Martin Thompson Mar 04 '13 at 13:57
  • No, when I try what you suggest, I get a MessageBox, `There is already a break point set for address NNNN` – User.1 Mar 04 '13 at 14:59
  • even with "advanced breakpoints"? – Martin Thompson Mar 05 '13 at 10:12
  • I don't think I have "advanced breakpoints". I edited my original post to include a screen cap of the options which MpLab here provides in memory breakpoints. – User.1 Mar 05 '13 at 15:51
  • Do you have the source-code of your routines? If yes, you can use eclipse to achieve this: Ctrl+Alt+H on a variable will show you what functions read and write to a variable. Try it by simply copying your code to a new eclipse project (make sure indexing is enabled). – Akhil Mar 08 '13 at 21:26
  • Thanks for the suggestion. I want to watch and see if one routine reads the value before the other has written to it; i.e., if the protocol is executing in proper order – User.1 Mar 08 '13 at 21:34

1 Answers1

0

Can you enclose your variable in a functions as below into a new .c file. set the define on the header file.

It might be a bit heavy but with a replace it could help. FILE and LINE are compiler flags to let you know from which file on the source code and at which line it is called. The Nop(); is there because the interrupt can happen few instruction late.

Add a watch on file and line to see where it's called from.

#define setvar(x) zsetvar(x, __FILE__, __LINE__)
#define getvar() zgetvar( __FILE__, __LINE__)


byte my_var;

void zsetvar(byte val, volatile char * file, volatile char * line)
{
 my_var = val;// set breakpoint
 Nop(); 
}
byte zreadvar(volatile char * file, volatile char * line)
{
 Nop(); //set breakpoint
 Nop();
 return my_var;
}
Damien
  • 1,492
  • 10
  • 32