Debugging tool for mbed enabled microcontrollers, especially for NUCLEO-F303RE and STM32F042F6P6.
Diff: debug_register.cpp
- Revision:
- 13:92533bcf6542
- Parent:
- 12:a8ab6e018422
- Child:
- 14:22a3b68860af
--- a/debug_register.cpp Mon May 13 08:39:42 2019 +0000 +++ b/debug_register.cpp Mon May 13 08:59:45 2019 +0000 @@ -26,6 +26,7 @@ void Debug_register::breakpoint(int line_number, uint32_t address){ uint32_t reg; //value of register + uint32_t tmp; //help variable char sign; //received character address -= address%4; //if address is not divisible by 4, set address to the closest lower number divisible by 4 @@ -76,17 +77,25 @@ address -= 0x4; // return cursor position to serial port area continue; }else if (sign == 'r' || sign == 'R'){ // if r was pressed, insert new address value - pc.printf("\r\e[K\e[12;0H\r\e[K\e[32;40m use l or j to xyzzzzzzzzx\e[97;40m"); + pc.printf("\r\e[K\e[12;0H\r\e[K\e[32;40m use l or j to move the cursor, esc to delete value or enter to continue\e[97;40m"); //pc.printf("\e[6;46H"); //move cursor to 6th row 46th column address = modify_value(address, 17); // insert or modify actual address(starting in 17th column) to read register value from it continue; }else if (sign == 'w' || sign == 'W'){ // if r was pressed, insert address value and register value to write register value on that address - pc.printf("\r\e[K\e[12;0H\r\e[K\e[32;40m use l or j to xxxxxxxxxxx\e[97;40m"); + pc.printf("\r\e[K\e[12;0H\r\e[K\e[32;40m use l or j to move the cursor, esc to delete value or enter to continue\e[97;40m"); //pc.printf("\e[6;46H"); address = modify_value(address, 17); // insert or modify actual address(starting in 17th column) to write register value on that address - pc.printf("\e[12;0H\r\e[K\e[32;40m use l or j to yyyyyyyx\e[97;40m"); + pc.printf("\e[12;0H\r\e[K\e[32;40m use l or j to move the cursor, esc to delete value or enter to continue\e[97;40m"); //pc.printf("\e[6;96H"); reg = *((volatile unsigned int *)address); //read register value from address + + tmp = reg; + pc.printf("\e[10;10H"); + for (int i = 0; i < 32; i++){ + pc.printf("%2d|",tmp >> (31 - i)); + tmp -= ((tmp >> (31 - i)) << (31 - i)); + } + reg = modify_value(reg, 40); // insert or modify actual register value(starting in 40th column) to that write register value on address *((volatile unsigned int *)address) = reg; // write new register value on the address continue; @@ -168,9 +177,8 @@ } pc.printf("\e[6;%dH", horizontal); - - + while(1){ sign = pc.getc(); if (sign == 13){