cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 chip keeps rebooting

rwmao
Senior
Posted on December 11, 2015 at 02:00

Hi all,

it is really very weird.

I am using stm32f411rct6,which has 256k program space and 128k ram.

Very often the program is weird, keeps rebooting or dead at all.

For example in a subroutine, when I delete 2 or 3 lines of code, it is working well. If I keep them, the chip keeps rebooting. I swear the lines I deleted have no any problem in logic.

Adding code somewhere else may also have the similar problem.

Sometime after I add the code, the chip is totally dead. No any response.

Please give me some clue to debug:

1. limit of ram, overflow?

Program Size: Code=28884 RO-data=456 RW-data=748 ZI-data=29364 

I don't really use too much space.

2. when chip keeps rebooting, I measured the voltage. It is fluctuating. But I swear the code I added, which causes the problem, have nothing to do with the power.

Please help.

14 REPLIES 14
rwmao
Senior
Posted on December 12, 2015 at 03:05

Thanks Clivel for your suggestion to check voltage.

Finally I figured it out.

It is caused by the power supply, which can only supply 25mA.

I put two REF3033 in parallel to provide 50mA supply. Now it works.

Why I say it was keeping resetting?

I put a code in the beginning to turn on a LED, wait 0.5s and turn it off. I observed the LED just keeping flashing. The period is around 25~50ms. I can make a conclusion that the code did run to the line for LED, but reset immediately.

Yesterday I put a code to show some text on LCD. The LCD is to show some info. If the program runs smoothly the LCD should refresh a few times and wait for button event. I observed that LCD keeps refreshing very fast. I can say that the chip keeps rebooting. 

Again how far the chip can go is very random.Sometime change of a line can cause a different behavior. I believe that is caused by the optimization of compiler.But I still can't understand why adding a line or removing a line can significantly change the power consumption.

Anyway after I upgraded the power supply, the system seems running well. I can go ahead for further programming.

Thanks again Clivel for your suggestion to check voltage

. Otherwise I will never figure it out.

rwmao
Senior
Posted on December 12, 2015 at 03:14

By the way Clivel, when I try to use STLINK to debug, before stepping into somewhere, it just says internal command error or unable to connect to the target, or the debug session was shutdown. The line causing the error is also random. 

It is very hard to debug. 

Now after I fixed the power supply problem, I can run the debug without issues.

It also tells me that the microcontroller may consume a power of much higher than 25mA.

Thanks

Posted on December 12, 2015 at 05:00

I was just pushing on the reset stuff to try an confirm it was more of a HW side issue, not sure I can really explain the SW side of it. I can't give you a hard number for current, most of it tends to get pulled by what it's driving externally.

Any way, glad you could get it figured out. You could try an external bench supply and get a feel for the current, and running at different frequencies.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rwmao
Senior
Posted on December 12, 2015 at 06:13

sure. thanks

rwmao
Senior
Posted on December 12, 2015 at 08:01

Clivel, may I ask you one more question?

When we use STM32 chip, is there a limit for the size of array and subroutine?

For example, if the chip has 128k ram, can I allocat 100k to an array(or buffer)?

Certainly the algorithm of program may take space such as 20k.

how about subroutine?

May I define a very long subroutine? For example main() or others.

What is the limit?

I just need a basic guideline.

Thanks