Monday, 15 September 2014

c - Incrementation doesn't go further than 0x01 -



c - Incrementation doesn't go further than 0x01 -

so i've got functions:

int f1(uint8_t* a, int b) { for(int = 0; < b; i++) f2(&a[i]); homecoming 1; } static void f2(uint8_t* a) { reg1 = *a; ... *a = reg2; }

"a" info register used buffer set info way main loop target function f2() through different wrapper functions.

"reg1" , "reg2" i/o registers , out of info passed "a". value of "reg2" implicitly changes while in f2() through hardware operations.

when watch variable changes in debug mode, next happens:

b = 2 declare = 0, < b call f2 increment i = 1, < b call f2 increment i = 0, < b

and since "i" never reaches 2, loop never ends. programme compiled , debugged iar ew avr. optimisation compiler turned off.

as @lundin says, seems memory corruption bug.

if can utilize debugger, seek inserting write-watchpoint on i. might help ^o^

(when thinking these codes, can assume a corrupted, , *a = reg2; might write on stack, , i changed)

c debugging increment microcontroller iar

No comments:

Post a Comment