Announcements

Webinar: Integrated solutions for smaller, simpler low-voltage motor control design.
Join the webinar to experience!

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

cross mob
FranzRibcek
Level 2
Level 2
25 sign-ins 10 replies posted 5 questions asked

Hello embedders,

I am here once again asking for your kind help! This time around, I need to understand how to configure stack overflow detection.

From the TLE9893 user manual, I gather that

  • User Stack Overflow Protection (USOP) needs be enabled,
  • A so-called guard band needs be established by means of upper and lower DSRAM addresses.

My startup_tle989x.S file assigns the stack a size of 512 bytes:

FranzRibcek_0-1702562923133.png

Also, at main entry point the stack pointer register has the value 0x180023B0 so I guess this is the initial stack pointer value.

I wrote the following code to implement USOP for testing purposes:

FranzRibcek_1-1702563055225.png

 

So from my understanding, guard band's lower limit is 0x18002320 whilst the upper limit is 0x18002390 for a total of 112 bytes.

Now, as reported from the linker, maximum stack usage is at least 144 bytes:

FranzRibcek_2-1702563308766.png

 

Therefore, it follows that the stack pointer must fall within the guard band region that I have defined, but actually no stack overflow is detected!

 

What am I getting wrong?

Kind regards,

FR

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Raj_C
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 replies posted

Hi @FranzRibcek,

Thanks for your patience!!

I have developed a sample example that detects the stack overflow and gives an indication by LED P0.2 on the TLE9893 Evalkit.

Summary:

Stack size is selected as 0x200 from tle9883_93.sct file

Stack start address is 0x1800 7C00.

STOF_ADDR_OFF_H = 0x16C8 and STOF_ADDR_OFF_L = 0x16BF after aligning in register this will set guard band between 0x18007B20 and 0x18007AFC.

 

Stack overflow is enabled in ConfigWizard as shown below.

Raj_C_0-1703139011362.png

 

Please let us know if you need further help.

Note: This example project is not the exact use case of stack overflow detection. It helps to trigger and analyze the stack overflow.

Thank you

Best Regards

Raj Chaudhari

 

View solution in original post

0 Likes
4 Replies
Raj_C
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 replies posted

Hi @FranzRibcek,

 

Please confirm if you have enabled the Stack Overflow NMI as shown below in NMICON (NMI Control Register).

Raj_C_0-1702628544590.png

 

And enable STOF_EN.

 

Raj_C_1-1702629991372.png

 

Please also let us know if you have developed a custom startup file or are using the default one.

 

Reference: TLE989x UM

Thank you

Best Regards

Raj Chaudhari

0 Likes
lock attach
Attachments are accessible only for community members.

Hello @Raj_C , and thanks for your kind reply.

I actually had not enabled bit NMICON.NMISTOFEN. It is now enabled. In spite of this, the stack overflow protection is not triggered and I never get inside the ISR I have programmed for testing.

I'll upload my startup file for you to inspect, which should be the default one. I had to change its extension to ".c" otherwise I wouldn't be able to upload it.

Kind regards,

FR

0 Likes
FranzRibcek
Level 2
Level 2
25 sign-ins 10 replies posted 5 questions asked

Up.

0 Likes
lock attach
Attachments are accessible only for community members.
Raj_C
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 replies posted

Hi @FranzRibcek,

Thanks for your patience!!

I have developed a sample example that detects the stack overflow and gives an indication by LED P0.2 on the TLE9893 Evalkit.

Summary:

Stack size is selected as 0x200 from tle9883_93.sct file

Stack start address is 0x1800 7C00.

STOF_ADDR_OFF_H = 0x16C8 and STOF_ADDR_OFF_L = 0x16BF after aligning in register this will set guard band between 0x18007B20 and 0x18007AFC.

 

Stack overflow is enabled in ConfigWizard as shown below.

Raj_C_0-1703139011362.png

 

Please let us know if you need further help.

Note: This example project is not the exact use case of stack overflow detection. It helps to trigger and analyze the stack overflow.

Thank you

Best Regards

Raj Chaudhari

 

0 Likes