Trouble setting a memory watchpoint with a specific value

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
WiFl_1166056
Level 3
Level 3
10 replies posted 10 questions asked 5 replies posted

I am trying to halt when a particular memory location gets set to a specific value.  I'm not looking for a particular variable to change, but rather a word in the stack.

I know how to set a watchpoint to break on write access.  That works fine, but it halts very frequently and I need it to halt only when a specific, invalid value is written.

I tried to add a "condition" to the memory access watchpoint, but this makes it either run so slowly that it never finishes timer interrupt handling, or it just locks up the debugger ("stop debugging" button in PSoC Creator button is ineffective).  I read something about modifying the linker file to place a variable at a specific location, then watch that variable for changes, but I'm not clear on how that's different nor exactly how to do it.

This is the watchpoint condition I am using:

(*((volatile unsigned long *)0x20007b18))==0x00002b4F

Is there another way to do this?  Is this slow behavior a bug in PSoC Creator, or maybe a limitation of the Cortex-M3?

Thanks!

-Will

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Will-san,

Today I borrowed a PSoC-5LP board from my colleague and ran tests using following main.c

==============================

#include "project.h"

#include <stdio.h>

char str[128] ; /* print buffer */

uint32_t count = 0 ;

// register uint32_t count asm("r6") ;

void init_hardware(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    UART_Start() ;

}

void UART_UartPutString(char *str)

{

    while(str && *str) {

        UART_PutChar(*str++) ;

    }

}

int main(void)

{

    uint32_t loop = 0 ;

  volatile int flag = 0 ;

   

    init_hardware() ;

    sprintf(str, "DWT test program (%s %s)\r\n", __DATE__, __TIME__) ;

    UART_UartPutString(str) ;

   

    for(;;) {

        if ((count % 0x10000) == 0) {

            sprintf(str, "Loop %d\r\n", loop++ ) ;

            UART_UartPutString(str) ;

            count = 0 ;

flag = 0 ;

        }

        count++ ;

#if 0

if (count == 0x100) {

    flag = 1 ;

}

#endif

    }

}

==============================

(1) count is a usual global variable and #if is 0 at the end part of the main.

    set Condition Break "count == 0x100" at the line of "count++"

    It took about 63sec to hit the first break.

(2) count is a register variable and #if is 0 at the end part of the main.

     set Condition Break "count == 0x100" at the line of "count++"   

    it took about 52sec to hit the first break.

(3) count is a usual global variable and #if if 1 at the end part of the main.

    set Break at the line of "flag = 1"

    it took less than a second to hit the first break.

So my current conclusion(s) are

1. Yes, using register variable makes the test faster but not quite.

2. Although modification to the source is required,

   placing a trap routine makes the "cost" of time much smaller.

moto

View solution in original post

0 Likes
7 Replies