View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
Locating Cause of Bit Corruption |
Posted: Sat Mar 10, 2007 3:06 pm |
|
|
3.236
18F2620
Hello All,
This is an ongoing problem that I was thought caused by a large array but it appears now that an int1 variable is getting corrupted and I need some help disecting the LST files.
If I declare and initialize an int1 flag variable in the MAIN section of code, it is corrupted under a very precise circumstance. I've checked to make sure I'm not using a = when I want to use ==, etc.
If I declare it outside of MAIN or make it STATIC inside MAIN the problem goes away.
Any suggestions? I'd be glad to post any more snippets that may help, code or LST.
Thanks,
John
Causes Problems:
Code: | .................... //------ Ambience Support
.................... int1 ambience_status = 0; //ambience on or off
1CF4: BCF x36.1
.................... int1 amb_spoolup_stat = 0; //ambience spooled up
1CF6: BCF x36.2
.................... int8 ticks = 0; //counter
1CF8: CLRF x43
.................... int8 ticks_to_next_event = 0;
1CFA: CLRF x44
.................... int1 next_event = 1; //flag for event type, 1 = on, 0 = off
1CFC: BSF x36.3
.................... int16 index_for_event = 0; //index of unit to turn on or off
1CFE: CLRF x45
1D00: CLRF x46
.................... |
Doesn't:
Code: | .................... //------ Ambience Support
.................... static int1 ambience_status = 0; //ambience on or off
.................... int1 amb_spoolup_stat = 0; //ambience spooled up
1CF6: BCF x36.1
.................... int8 ticks = 0; //counter
1CF8: CLRF x43
.................... int8 ticks_to_next_event = 0;
1CFA: CLRF x44
.................... int1 next_event = 1; //flag for event type, 1 = on, 0 = off
1CFC: BSF x36.2
.................... int16 index_for_event = 0; //index of unit to turn on or off
1CFE: CLRF x45
1D00: CLRF x46
.................... |
|
|
|
Ttelmah Guest
|
|
Posted: Sat Mar 10, 2007 3:57 pm |
|
|
Look at the symbol table.
What is stored in location 0x35?. What operations do you perform on this?. The fault is fairly 'classic', for something just in front of the variable, overwriting it. When you declare it as static, it is put into a different memory location.
Best Wishes |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Sat Mar 10, 2007 6:18 pm |
|
|
RJ,
Thanks. Now it's even more bizarre. The location previous is an int8 variable declared and initialized right before the flag variable. The strange thing is, it's not ever used... it was an old index variable that was left over from some old code.
I'm looking further upstream and I'll let you know if I find anything.
John |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Sat Mar 10, 2007 7:40 pm |
|
|
I finally tracked it down to a mix of types in an equation to find an array index..... |
|
|
|