Home > other >  What causes STM32 program after bigger ADC don't work properly?
What causes STM32 program after bigger ADC don't work properly?

Time:10-08

Have you encountered such a problem, the program seems to be more than 60 KB after adc conversion of data is very strange, I am using STM32L151 series;
By looking at the register, the adc CR2 registers has changed;




At present there are two solutions:
(1) the control program does not exceed 60 KB;
(2) force the CR2 register assignment into the correct values;

I want to know where is the root cause of the problem, in this waiting for you a great god reply ~

CodePudding user response:

Did use freertos, stack space set up reasonable?

CodePudding user response:

No operating system, the same program, O0 compiled 66 KB, 62 KB is O1 compiled here are normal, that's why I said they exceed 60 KB program problem (I doubt 64 KB is a watershed).

CodePudding user response:

refer to listen to the rain falls on the second floor response:
no operating system, the same program, O0 compiled 66 KB, 62 KB is O1 compiled here are normal, that's why I said they exceed 60 KB program problem (I doubt 64 KB is a watershed).

See the inside of the ld file configuration

CodePudding user response:

Ld files, not only the SCT, the stuff is generated by the project yourself

CodePudding user response:

Feeling is the stack has been destroyed

CodePudding user response:

Your code has no intention to rewrite the register

CodePudding user response:

Your code has no intention to rewrite the register

CodePudding user response:

fog oasis reference 5 floor response:
feeling is stack has been destroyed
impossible, other function is normal

CodePudding user response:

refer to 7th floor hualantech response:
should be your code has no intention to rewrite the register
should not, I just change from O0 optimization level to O1 is normal.

CodePudding user response:

By far the more than 40 KB program

CodePudding user response:

The
references to the tenth floor Haiguozhe response:
now more than 40 KB program
when you have an opportunity to more than 64 KB to visit me here again ~

CodePudding user response:

You this is not the size of the program problem, the symptoms of stack overflow

CodePudding user response:

You this is a typical stack overflow problem, O0 compilation, is the code does not make any optimization; O1 compilation is optimized at compile time, part of the problem at compile time to optimize the you, you check the problem variables defined and used

CodePudding user response:

reference 13 floor city mountain son reply:
you this is a typical stack overflow problem, O0 compilation of code does not make any optimization; O1 compilation is optimized at compile time, part of the problem at compile time to optimize the you, you are the problem check variables defined as well as using
optimize level has no effect on RAM basically, another stack is big enough

CodePudding user response:

On the 14th floor and listen
reference rain response:
Quote: refer to the 13th floor city mountain son reply:

You this is a typical stack overflow problem, O0 compilation, is the code does not make any optimization; O1 compilation is optimized at compile time, part of the problem at compile time to optimize the you, you are the problem check variables defined as well as using
optimize level has no effect on RAM basically, additional stack enough

Stack overflow with stack is big enough it doesn't matter, this is the programming code standard problem, for example, define a char variable a, then give a memcpy (& amp; A, "aa", 2); Can all result in a stack overflow, such as the back of the stack data are changed to the unconscious

CodePudding user response:

On the 14th floor and listen
reference rain response:
Quote: refer to the 13th floor city mountain son reply:

You this is a typical stack overflow problem, O0 compilation, is the code does not make any optimization; O1 compilation is optimized at compile time, part of the problem at compile time to optimize the you, you are the problem check variables defined as well as using
optimize level has no effect on RAM basically, additional stack enough

This gives you, define a variable, the system will open up a space on the stack is used to store the variable, but in to the value of the stack space space is greater than the definition of space, the stack near space will be changed unconsciously

CodePudding user response:

reference 16 floor city mountain son reply:
Quote: listen to the rain fall reference 14 floor response:

Quote: refer to the 13th floor city mountain son reply:

You this is a typical stack overflow problem, O0 compilation, is the code does not make any optimization; O1 compilation is optimized at compile time, part of the problem at compile time to optimize the you, you are the problem check variables defined as well as using
optimize level has no effect on RAM basically, additional stack enough

This gives you, define a variable, the system will open up a space on the stack is used to store the variable, but in to the value of the stack space space is greater than the definition of space, the stack near the space will be changed unconsciously
what you say is can analysis for some problems, but I this is very strange, if I deleted some irrelevant statements, reduce program size, ADC is normal again, what do you think that it is the problem that the compiler, but I'm not good at assembly, so this problem I also not too good.

CodePudding user response:

refer to 17th floor listening rain response:
Quote: refer to the 16th floor city mountain son reply:

Quote: listen to the rain fall reference 14 floor response:

Quote: refer to the 13th floor city mountain son reply:

You this is a typical stack overflow problem, O0 compilation, is the code does not make any optimization; O1 compilation is optimized at compile time, part of the problem at compile time to optimize the you, you are the problem check variables defined as well as using
optimize level has no effect on RAM basically, additional stack enough

This gives you, define a variable, the system will open up a space on the stack is used to store the variable, but in to the value of the stack space space is greater than the definition of space, the stack near the space will be changed unconsciously
what you say is can analysis for some problems, but I this is very strange, if I deleted some irrelevant statements, reduce program size, ADC is normal again, what do you think that it is the problem that the compiler, but I'm not good at assembly, so this problem I also not too good.

You compare the assembly code, don't you change the stack data, the function will be stack operation

CodePudding user response:

Program size is it doesn't matter, as long as you can compile download, run is no problem, I at ordinary times in the project is often program size close to the storage limit haven't seen this problem, a good check stack operation

CodePudding user response:

Watch the address of the register, try the monitoring the address data breakpoints, although want to get, but even on memory, from an SRAM stepped on PERIPH that is too much

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related