Hallo,
ich habe folgende kleine Funktion mit der aktuellen Atmel AVR Toolchain
(bewusst nicht auf den Wertebereich begrenzt):
1 | static uint8_t Regler ( int16_t U_soll, int16_t U_ist )
|
2 | {
|
3 | static int32_t Errorsum;
|
4 | int16_t y = 0;
|
5 | int16_t Diff = U_soll - U_ist;
|
6 |
|
7 | Errorsum += Diff;
|
8 | if ( Errorsum > ERRORSUM_MAX ) Errorsum = ERRORSUM_MAX;
|
9 | if ( Errorsum < 0 ) Errorsum = 0;
|
10 |
|
11 | y = (Errorsum/KI) + (Diff * KP);
|
12 |
|
13 | return y;
|
14 | }
|
Warum meckert der GCC hier nicht, dass ich mit y den Wertebereich eines
uint8_t verlasse?
Habe alles an:
-x c -funsigned-char -funsigned-bitfields -DDEBUG -DF_CPU=9600000 -Os
-ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2
-Wall -Wextra -Werror -pedantic -pedantic-errors -mmcu=attiny13a -c
-std=gnu99 -MD -MP -MF "main.d" -MT"main.d" -MT"main.o" -o "main.o"
".././main.c"