cancel
Showing results for 
Search instead for 
Did you mean: 

STemWin BUTTON_SetText() made hardfault

ertanaldogan
Associate II
Posted on August 07, 2014 at 09:58

Hello,

when i call 

BUTTON_SetText()

hard fault error occured. What is the possible reason? I can create button. I can write messages on screen but i cannot set button name. 

#stemwin #stemwin
3 REPLIES 3
Posted on August 07, 2014 at 14:17

That you're passing an invalid parameter?

You don't provide a code fragment, or processor state information at the fault, so try to refine your failure case so you can demonstrate it to people in a position to fix/address it.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
ertanaldogan
Associate II
Posted on August 07, 2014 at 20:49

Hello,

There is an image below which shows ''Call Stack'' window and another image for Fault Reports window. These are taken when hard fault occured.

In call stack, before hard fault, i guess the error was on 0x08007926. So below you can see the disassembly codes:

0x080078E4 4201 TST r1,r0

0x080078E6 9802 LDR r0,[sp,&sharp0x08]

0x080078E8 D00B BEQ 0x08007902

0x080078EA B920 CBNZ r0,0x080078F6

0x080078EC 2001 MOVS r0,&sharp0x01

0x080078EE E9CD4001 STRD r4,r0,[sp,&sharp0x04]

0x080078F2 F8D5B06C LDR r11,[r5,&sharp0x6C]

0x080078F6 9803 LDR r0,[sp,&sharp0x0C]

0x080078F8 F82B0B02 STRH r0,[r11],&sharp0x02

0x080078FC F10A0001 ADD r0,r10,&sharp0x01

0x08007900 E012 B 0x08007928

0x08007902 2801 CMP r0,&sharp0x01

0x08007904 D111 BNE 0x0800792A

0x08007906 1E63 SUBS r3,r4,&sharp1

0x08007908 2000 MOVS r0,&sharp0x00

0x0800790A 9002 STR r0,[sp,&sharp0x08]

0x0800790C 9807 LDR r0,[sp,&sharp0x1C]

0x0800790E 9000 STR r0,[sp,&sharp0x00]

0x08007910 4602 MOV r2,r0

0x08007912 F8D5C0A8 LDR r12,[r5,&sharp0xA8]

0x08007916 4628 MOV r0,r5

0x08007918 9901 LDR r1,[sp,&sharp0x04]

0x0800791A 47E0 BLX r12

0x0800791C F8D52138 LDR r2,[r5,&sharp0x138]

0x08007920 4651 MOV r1,r10

0x08007922 6EE8 LDR r0,[r5,&sharp0x6C]

0x08007924 4790 BLX r2

0x08007926 2000 MOVS r0,&sharp0x00

0x08007928 4682 MOV r10,r0

0x0800792A 1C64 ADDS r4,r4,&sharp1

0x0800792C 1C76 ADDS r6,r6,&sharp1

0x0800792E 2E08 CMP r6,&sharp0x08

0x08007930 D101 BNE 0x08007936

0x08007932 2600 MOVS r6,&sharp0x00

0x08007934 1C7F ADDS r7,r7,&sharp1

0x08007936 F1A90001 SUB r0,r9,&sharp0x01

0x0800793A EA5F0900 MOVS r9,r0

0x0800793E D1CE BNE 0x080078DE

0x08007940 F1BA0F00 CMP r10,&sharp0x00

0x08007944 D0C1 BEQ 0x080078CA

0x08007946 9807 LDR r0,[sp,&sharp0x1C]

0x08007948 1E63 SUBS r3,r4,&sharp1

0x0800794A 9000 STR r0,[sp,&sharp0x00]

0x0800794C 4602 MOV r2,r0

0x0800794E F8D540A8 LDR r4,[r5,&sharp0xA8]

0x08007952 4628 MOV r0,r5

0x08007954 9901 LDR r1,[sp,&sharp0x04]

0x08007956 47A0 BLX r4

0x08007958 F8D52138 LDR r2,[r5,&sharp0x138]

0x0800795C 6EE8 LDR r0,[r5,&sharp0x6C]

0x0800795E B009 ADD sp,sp,&sharp0x24

0x08007960 4651 MOV r1,r10

0x08007962 E8BD4FF0 POP {r4-r11,lr}

0x08007966 4710 BX r2

0x08007968 7839 LDRB r1,[r7,&sharp0x00]

0x0800796A FA28F006 LSR r0,r8,r6

0x0800796E 4201 TST r1,r0

0x08007970 D00D BEQ 0x0800798E

0x08007972 F8D530EC LDR r3,[r5,&sharp0xEC]

0x08007976 4621 MOV r1,r4

0x08007978 4658 MOV r0,r11

This is my code and when i dont use BUTTON_SetText, hard fauld error not occured. But the button drawn with out any text on it. When i use BUTTON_SetText() but i dont use GUI_Exec(), hard fault error isnt be occured but the button is not drawn. When i use BUTTON_SetText() and GUI_Exec(), after executing GUI_Exec() the hard fault is occured.

static void _DemoButton(void) {

BUTTON_Handle hButton;

GUI_SetFont(&GUI_Font8x16);

GUI_DispStringHCenterAt(''Click on button...'', 160, 90);

//

// Create the button and set text

//

hButton = BUTTON_CreateEx(110, 110, 100, 40, hParent, WM_CF_SHOW,0,1);

BUTTON_SetText(hButton, ''Click me...'');

}

void EMain(void){

GUI_Init();

GUI_SetBkColor(GUI_RED);

GUI_Clear();

GUI_SetFont(&GUI_Font8x16);

_DemoButton();

GUI_Exec();

while(1){

}

}

Any comment?

Posted on August 07, 2014 at 22:31

Actually I think that's the return address, the code that failed was in/at R2 that it just tried to call.

Perhaps this is a routine pointed to inside a structure at offset +0x138

I think you need to pull the register content pushed onto the stack for R2 and PC
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..