View previous topic :: View next topic |
Author |
Message |
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Mon Feb 03, 2020 3:35 pm |
|
|
For a specific number of variables I can use the 16bit size variable. Not to all. But I'm afraid that this error could occur in another variable. This variable is easily more or less easy to debug. I have others that are very very difficult to check.
About the array of variables. I can't use the const because some of these variables directly access from another part of the program. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Tue Feb 04, 2020 1:50 am |
|
|
The suggestion from Allen that this could be the variable corruption
problem with int8 variables shared to ones used inside an interrupt
is a very likely possibility. This was fixed the compiler version after he
found this, and I had forgotten it could still apply at your compiler version.
Try the solution to this. Word align the variable and see if it disappears. So:
Code: |
unsigned int8 sist_prog_val = 0 __attribute__((aligned(2)));
|
If it starts working OK, then you have found the issue.
Where are the variables:
sist_prog_val
pointer_eeprom_adc_vals
actually 'used'. Are either used inside an interrupt?. |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Tue Feb 04, 2020 3:33 am |
|
|
Hi Ttelmah,
Your suggestion is: in all 8bit global variables that could be used within the interrupts declared them as follows:
Code: | unsigned int8 sist_prog_val = 0 __attribute__((aligned(2))); |
correct?
and about the ones that are not used in the interrupts? should also be declared as you mentioned?
I have tried to put in all global variables, but somehow the compiler says that hasn't enough space.. before changing, my program with the printf occupies 97% after changing all the 8 bit variables "used" in the interrupt, it says it is need more 248 bytes (WTF??!!)
By the way, in the int1, int16 and int32 variables that is not necessary, wright? or do you suggest to do something similar? |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Tue Feb 04, 2020 4:07 am |
|
|
Hi allenhuffman
About the array of variables that I use in some of the versions CCS (and that don't work in the 5.092 ) is something like:
Code: |
Int8 var1 =0;
Int8 var2 =0;
Int8 var3 =0;
Int8 var4 =0;
Int8 arr_var[4] ={var1,var2,var3,var4};
Int8 my_buffer[4] ={0x08,0x14,0x45,0x78};
////-------------//////////
for (i = 0; i < 4; i++)
{
*((char *)arr_var[i]) = my_buffer[i];
} |
and the opposite is something like:
Code: | for (i = 0; i < 4; i++)
{
my_buffer[i] = *((char *)arr_var[i]);
} |
I hope it helps.
By the way, the attribute , can only be used with constants (like defines) variables. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Tue Feb 04, 2020 4:16 am |
|
|
Any 8bit variable that is used inside an interrupt and may also be accessed
outside.
Look through your symbol list. Identify all 8bit variables like this that
share a memory 'word' with a variable that does not (remember words
start on even addresses). |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Tue Feb 04, 2020 7:49 am |
|
|
Ttelmah, I have changed the code according to your idea... and now i'm making the first tests... for know (couple of hours..) so good... lets see... |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 552 Location: Des Moines, Iowa, USA
|
|
Posted: Tue Feb 04, 2020 8:27 am |
|
|
Ttelmah wrote: | The suggestion from Allen that this could be the variable corruption
problem with int8 variables shared to ones used inside an interrupt
is a very likely possibility. This was fixed the compiler version after he
found this, and I had forgotten it could still apply at your compiler version |
It did get fixed??? I missed it in the release notes. I'll go check. http://www.ccsinfo.com/devices.php?page=versioninfo _________________ 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 ?
Last edited by allenhuffman on Tue Feb 04, 2020 8:33 am; edited 1 time in total |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 552 Location: Des Moines, Iowa, USA
|
|
Posted: Tue Feb 04, 2020 8:28 am |
|
|
And note --- this is not limited to YOUR variables. Using any CCS code that uses an int8 internally (like the I2C code we are using) could also cause it. In which case, I don't know of any workaround other than to not use any 8-bit values, or use that attribute to make them word-aligned. _________________ 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 ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Tue Feb 04, 2020 8:44 am |
|
|
Version info misses a huge amount of stuff.
Yes, they almost immediately changed how byte accesses are actually
performed to stop this. |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 552 Location: Des Moines, Iowa, USA
|
|
Posted: Tue Feb 04, 2020 8:49 am |
|
|
Ttelmah wrote: | Version info misses a huge amount of stuff.
Yes, they almost immediately changed how byte accesses are actually
performed to stop this. |
How did you find out? We still do extra steps every time we build, and it will be nice to no longer have to do that. _________________ 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: Tue Feb 04, 2020 9:02 am |
|
|
In all int8 variables placed on the odd position I have used the following code:
Code: | unsigned int8 sist_prog_val = 0 __attribute__((aligned(2))); |
eventually, I can try to insert the above atribute in all int8 variables (I have space.. )
So you say that in the new version 5.092 that is fixed? it is not need any sort of workaround?
By the way, about the array variables problem that I also mentioned in this thread that doesn't work in the 5.092 and work in the other versions, do you have any workaround? or CCS will release a new version fixing all this? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Tue Feb 04, 2020 9:10 am |
|
|
It's not actually the alignment, but the memory access used. They don't
change the alignment, but alter how the variables are accessed. I'd assumed
they would have contacted you straight away to say this. The changes
appeared in the very next compiler. |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Fri Feb 07, 2020 3:42 am |
|
|
Ttelmah, it really seems that you figured it out.. until now I didn't have any other problem..
I really would appreciate for your time and effort
Thanks to all the persons that help me (PCM programmer, temtronic and allenhuffman). |
|
|
|