Hi,
I tried using an array to replace a giant switch case function.
if (DIF <= 25) { int table1[36] = { 5, 5, 5, 5, 5, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 38, 39, 40, 40 }; test = Test_DEMOD1-5; VERH_int = table1[test]; } else { int table2[139] = { 40, 40, 41, 41, 42, 42, 43, 43, 43, 44, 44, 45, 45, 46, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 50, 51, 51, 52, 52, 53, 53, 53, 54, 54, 55, 55, 56, 56, 56, 57, 57, 58, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 63, 64, 64, 65, 65, 66, 66, 66, 67, 67, 68, 68, 69, 69, 69, 70, 70, 71, 71, 72, 72, 72, 73, 73, 74, 74, 75, 75, 76, 76, 76, 77, 77, 78, 78, 79, 79, 79, 80, 80, 81, 81, 82, 82, 82, 83, 83, 84, 84, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85}; test = DIF-11; VERH_int = table2[test]; }
In general only table 2 gets excecuted, table 1 is some kind of backup. The variables are defined globally for debugging. However everytime the array gets called the program will freeze in hardfault with the Error mentioned in the title. At the beginning I thought that I might not be allowed to calculate in square brackets, thats why i introduced the new variable test for my necesarry calculations. Since that didnt bring any significant change except for the programm running through the array 2-3 times (and not reading any values) I decided to write this post. Could the be some kind of memory exception due to the size of my array?
kind regards,
Paul