Debugging tool for mbed enabled microcontrollers, especially for NUCLEO-F303RE and STM32F042F6P6.
Diff: debug_serial.cpp
- Revision:
- 15:83d4dced2a28
- Parent:
- 12:a8ab6e018422
- Child:
- 22:ac9b2cbb31a8
--- a/debug_serial.cpp Mon May 13 11:04:54 2019 +0000 +++ b/debug_serial.cpp Mon May 27 02:11:53 2019 +0000 @@ -9,13 +9,15 @@ // init function //------------------------------------------------------------------------------------------------------------------ void Debug_serial::init() { - pc.printf("\ec"); - wait_ms(50); + pc.printf("\ec"); //clear entire screen + wait_ms(50); //wait until clearing is done pc.printf("-----------------\n\r|\e[1m\e[97;40m\e[93;40mBREAKPOINT AREA\e[22m\e[97;40m|\n\r-----------------\n\r\033[s"); pc.printf("serial successfully initialised\n\r\e[32;40mto start program press any button\e[97;40m"); - breakpoint_count=0; - pc.getc(); + breakpoint_count = 0; //set breakpoint count to 0 + pc.getc(); // wait until user sends any character pc.printf("\r\e[2K\e[31;40mprogram is running\e[97;40m\r"); + + // information about last three breakpoints break_line[0] = -1; break_line[1] = -1; break_line[2] = -1; @@ -25,7 +27,6 @@ pc.printf("\033[14;0H------------------\n\r|\e[1m\e[93;40mSERIAL PORT AREA\e[22m\e[97;40m|\n\r------------------\n\r\033[s"); } - // perform one breakpoint without printing variable //------------------------------------------------------------------------------------------------------------------ void Debug_serial::breakpoint(int line_number) { @@ -85,7 +86,7 @@ strcpy(var[2], var[1]); strcpy(var[1], var[0]); - sprintf(var[0],"Address 0x%8x Value 0x%8x", address - address%4, read_word(address - address%4, 0x0)); + sprintf(var[0],"Address 0x%8x Value 0x%8x", address - address%4, *((volatile unsigned int *)(address - address % 4))); print_3_breaks(line_number); } @@ -146,7 +147,7 @@ //------------------------------------------------------------------------------------------------------------------ void Debug_serial::print_3_breaks(int line_number){ pc.printf("\e[s"); //save current cursor position - wait_ms(50); + wait_ms(50); // wait until saving is done breakpoint_count++; break_line[2] = break_line[1]; //save information about line of breakpoints break_line[1] = break_line[0];