View previous topic :: View next topic |
Author |
Message |
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Mon Feb 03, 2020 6:24 am |
|
|
Even though, a hang should block the micro for a couple of microseconds/seconds, not changing the value of the variables in RAM, correct? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9134 Location: Greensville,Ontario
|
|
Posted: Mon Feb 03, 2020 7:39 am |
|
|
You could try reordering the RAM locations. If the error follows the variable, then you've eliminated a possible bad RAM cell (physical defect). Or maybe it's a 'banking' problem, some 'glitch' affects 'a' which then affects 'b'. ?
Maybe put a small delay (1ms ?) between transferring the EEPROM data to RAM, and another before testing the RAM data.
Somehow you need to find out where/when the error occurs.
Could be a long 'process of elimination'.....sigh |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19256
|
|
Posted: Mon Feb 03, 2020 8:46 am |
|
|
My suggestion on the ADC, is _required_. Not optional.
However the point is that you can reduce the divisor used so the actual
ADC conversion will be faster than it currently is.
Read the errata for the chip. Paragraph 5. The three fixes are:
1) Do as I suggest and drop the clock rate when reading the ADC.
2) Sleep the PIC for the conversion.
3) Manually stop the conversion between exactly 10.5 and 11 Tad cycles
after triggering the conversion.
It's a real 'pig' of a problem with that particular PIC. |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Mon Feb 03, 2020 9:44 am |
|
|
Ttelmah:
I'm using the micro with the A9 revision:
Quote: | Device Id Revision = 0x9 |
so according to the Errata, this issue (ADC) affect only the versions A2, A2 and A5 ... so it should not be necessary to use your workaround. That is why I didn't implement the workaround....
but anyway, I will try to put all the code working at 8MHZ and I will try test it...
Temtronic:
I will also try to test you suggestion (reording the RAM locations)..
about the eeprom to ram transfering I really don't think we have a problem there, because I only make the reading on reboot of the system and after that I use only the RAM value.. and the error occurs after a couple hours and/or days working (whithout reboot)...so it should be another thing... I think |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Mon Feb 03, 2020 11:12 am |
|
|
furthermore.. in my version compiler, the
doesn't exist.
I have to put something like:
Code: | setup_oscillator(OSC_PLL_ON|OSC_8MHz); |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19256
|
|
Posted: Mon Feb 03, 2020 1:14 pm |
|
|
OK. I just wondered if an older revision silicon might exist on just some
of the boards. This would then explain your comment that this is only
happening on some boards....
Unless you have actually checked the DEVID, don't assume that buying
more recently automatically gives a recent revision. |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 537 Location: Des Moines, Iowa, USA
|
|
Posted: Mon Feb 03, 2020 2:38 pm |
|
|
Just a side note ... we ran into an issue with an int8 that was being corrupted by an ISR accessing another int8 that shared the same 16-bit area in memory:
http://www.ccsinfo.com/forum/viewtopic.php?t=58217
At a certain size in code, the compiler has to generate extra steps to access the memory and can be generating code to do something like "load 8-bit, modify, store 8-bit" and during that moment, the ISR ran code that was doing the same to the other half, corrupting our 8-bit value.
We now avoid using 8-bit values wherever possible, since it was "our" local 8-bit value that was being messed up by a CCS function (I2C code) that we had no control over.
I even wrote a simple symbol table parser that would show all the 8-bit values that shared memory with other values, and we use that to look for any potential future issues. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 537 Location: Des Moines, Iowa, USA
|
|
Posted: Mon Feb 03, 2020 2:47 pm |
|
|
Also, there is an issue through 5.092 with how offsets to an array of structures are calculated that can cause setting array values to write to memory past the structure. i.e.:
Code: | MyStruct foo[10];
- - - -
extern MyStruct foo[];
foo[0].a = 10;
foo[1].a = 11;
foo[2].a = 12; |
We've created code where accesses past [0] go beyond the memory for the entire array. CCS is aware of this and already provided me a few updated DLLs for testing which resolve this corruption.
There was a third issue with arrays that was clobbering our memory, but that one also looks like it will be fixed in an upcoming release. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Mon Feb 03, 2020 3:10 pm |
|
|
Ttelmah,
In fact you are correct. Eventually I can have several silicon versions of the micro on my control boards. But, indeed I ran this error in a particular micro that has the newest version. That is why I assume that could be an variable corruption.
Allenhuffman, I use only 16 bits variables when is really need, because in a 8 bit microcontroller. Handling 16 bit takes a lot of effort and ROM space. So we need to keep very strict int the size of the variables. And indeed this problem is really getting me nuts. Because it only occurs sometimes and after a hours or days working. Related to your last case I had tried in a another computer that had the 5.092 compile a program that has an array of variables:
Code: |
Int8 var1 =0;
Int8 var2 =0;
Int8 var3 =0;
Int8 var4 =0;
Int8 arr_var[4] ={var1,var2,var3,var4} ; |
This code works well in the 5. 089 but it doesn't work in the 5.092. |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 537 Location: Des Moines, Iowa, USA
|
|
Posted: Mon Feb 03, 2020 3:14 pm |
|
|
ralph79 wrote: | ...related to your last case I had tried in a another computer that had the 5.092 compile a program that has an array of variables:
Int8 var1 =0;
Int8 var2 =0;
Int8 var3 =0;
Int8 var4 =0;
Int8 arr_var[4] ={var1,var2,var3,var4} ;
This code works well in the 5. 089 but it doesn't work in the 5.092... |
That's an interesting one. Did you submit it to CCS support? They have been very responsive for me.
I also noted you can't do:
Code: | int x = getXValue(); |
...but you can do...
Code: | int x;
x = getXValue(); |
Many of my "portable C" functions don't port over to CCS as easily as I'd like ;-) _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 537 Location: Des Moines, Iowa, USA
|
|
Posted: Mon Feb 03, 2020 3:21 pm |
|
|
ralph79 wrote: | ...related to your last case I had tried in a another computer that had the 5.092 compile a program that has an array of variables: |
My GCC/x86 cannot compile that code either. I have seen variables used for array declarations like:
int x = 10;
int array[x];
...under CCS (I didn't know that was possible; it wasn't in the old level of C I learned on ages ago). _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Mon Feb 03, 2020 3:22 pm |
|
|
I didn't send to ccs, until now, because I really need to find and solve this error. It is very urgent. After that I will have some time to solve the issue of the 5.092. It is an program that has still a time to market of a couple of weeks. So my urgency is how I can solve or at least reduce at most this variable corruption. |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 537 Location: Des Moines, Iowa, USA
|
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 537 Location: Des Moines, Iowa, USA
|
|
Posted: Mon Feb 03, 2020 3:26 pm |
|
|
Try the "const" keyword:
Code: | const int8 var1 = 0;
const int8 var2 = 0;
const int8 var3 = 0;
const int8 var4 = 0; |
_________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Mon Feb 03, 2020 3:30 pm |
|
|
I manage to put it working also in ccs and in xc8/xc32. It had worked in some of the versions of the ccs. But it doesn't work correctly in the 5.092. |
|
|
|