Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 void ShiftToRecords(int8 *ptr, int8 iterNum, int1 comType) { iterNum++; blankShiftNumber = 24 - iterNum; while(iterNum != 0) { shiftBit = shift_right(inputRecordsStable, 3, 0); shift_right(ptr, 3, shiftBit); iterNum--; } while(blankShiftNumber != 0) { shift_right(ptr, 3, 0); /* **** The reset evet happens in this line **** */ blankShiftNumber--; }
_bif int1 shift_right(unsigned int8* address, unsigned int8 bytes, int1 value);
.................... shift_right(ptr, 3, 0);
07D5C: MOVFF 441,FEA
07D60: MOVFF 440,FE9
07D64: MOVLW 02
07D66: ADDWF FE9,F
07D68: BCF FD8.0
07D6A: RRCF FED,F
07D6C: RRCF FED,F
07D6E: RRCF FED,F
.................... void ShiftToRecords(int8 *ptr, int8 iterNum, int1 comType)
.................... {
.................... iterNum++;
*
07D10: MOVLB 4
07D12: INCF x42,F
.................... blankShiftNumber = 24 - iterNum;
07D14: MOVLW 18
07D16: BSF FD8.0
07D18: SUBFWB x42,W
07D1A: MOVLB 0
07D1C: MOVWF xFB
....................
.................... while(iterNum != 0)
07D1E: MOVLB 4
07D20: MOVF x42,F
07D22: BZ 7D56
.................... {
.................... shiftBit = shift_right(inputRecordsStable, 3, 0);
07D24: BCF 51.7
07D26: BCF FD8.0
07D28: MOVLB 0
07D2A: RRCF xCA,F
07D2C: RRCF xC9,F
07D2E: RRCF xC8,F
07D30: BNC 7D34
07D32: BSF 51.7
.................... shift_right(ptr, 3, shiftBit);
07D34: BTFSC 51.7
07D36: BRA 7D3C
07D38: BCF FD8.0
07D3A: BRA 7D3E
07D3C: BSF FD8.0
07D3E: MOVFF 441,FEA
07D42: MOVFF 440,FE9
07D46: MOVF FEC,F
07D48: MOVF FEC,F
07D4A: RRCF FED,F
07D4C: RRCF FED,F
07D4E: RRCF FED,F
.................... // kaydırılmasında kullan.
.................... iterNum--;
07D50: MOVLB 4
07D52: DECF x42,F
07D54: BRA 7D20
.................... }
....................
.................... while(blankShiftNumber != 0)
07D56: MOVLB 0
07D58: MOVF xFB,F
07D5A: BZ 7D74
.................... {
.................... shift_right(ptr, 3, 0);
07D5C: MOVFF 441,FEA
07D60: MOVFF 440,FE9
07D64: MOVLW 02
07D66: ADDWF FE9,F
07D68: BCF FD8.0
07D6A: RRCF FED,F
07D6C: RRCF FED,F
07D6E: RRCF FED,F
.................... blankShiftNumber--;
07D70: DECF xFB,F
07D72: BRA 7D58
.................... }
....................
.................... inputRecordsStable[0] = 0;
07D74: CLRF xC8
.................... inputRecordsStable[1] = 0;
07D76: CLRF xC9
.................... inputRecordsStable[2] = 0;
07D78: CLRF xCA
....................
.................... return;
07D7A: RETURN 0
.................... }
I apologize for overlooking the point. I see you are using CCS C. Which version, exactly?As I informed earlier, shift_right is compiler's function, and I can't see the c source code.
Maybe this one will be useful, the assembly source of ShiftToRecords function complete:
shift_right(&ptr, 3, 0);
Index register FSR0 is loaded with ptr value. So either ptr is corrupted or FSR0 is changed in an interrupt function.but in the second it is shifting the stack pointer. Only possible branching is the timer interrupt. So I don't know which part of the code should I look?
void ShiftToRecords(int8*, int8, int1);
int recordsMix[3];
int maxFloor; // this value is read from the eeprom, it doesn't effect our case even if unexpectedly high
ShiftToRecords(recordsMix, maxFloor, PARALLEL_DATA);
void ShiftToRecords(int8 *ptr, int8 iterNum, int1 comType)
{
pointer0 = ptr;
iterNum++;
blankShiftNumber = 24 - iterNum;
while(iterNum != 0)
{
shiftBit = shift_right(inputRecordsStable, 3, 0);
shift_right(pointer0, 3, shiftBit);
iterNum--;
}
while(blankShiftNumber != 0)
{
shift_right(pointer0, 3, 0);
blankShiftNumber--;
}
inputRecordsStable[0] = 0;
inputRecordsStable[1] = 0;
inputRecordsStable[2] = 0;
return;
}
A sample function call and the parameters which are defined before calling the function:
Code:int maxFloor; // this value is read from the eeprom, it doesn't effect our case even if unexpectedly high
.................... void ShiftToRecords(int8 *ptr, int8 iterNum, int1 comType)
.................... {
.................... iterNum++;
*
07D10: MOVLB 4
07D12: INCF x42,F
.................... blankShiftNumber = 24 - iterNum;
07D14: MOVLW 18
07D16: BSF FD8.0
07D18: SUBFWB x42,W
07D1A: MOVLB 0
07D1C: MOVWF xFB
....................
.................... while(iterNum != 0)
07D1E: MOVLB 4
07D20: MOVF x42,F
07D22: BZ 7D56
.................... {
.................... shiftBit = shift_right(inputRecordsStable, 3, 0);
07D24: BCF 51.7
07D26: BCF FD8.0
07D28: MOVLB 0
07D2A: RRCF xCA,F
07D2C: RRCF xC9,F
07D2E: RRCF xC8,F
07D30: BNC 7D34
07D32: BSF 51.7
.................... shift_right(ptr, 3, shiftBit);
07D34: BTFSC 51.7
07D36: BRA 7D3C
07D38: BCF FD8.0
07D3A: BRA 7D3E
07D3C: BSF FD8.0
07D3E: MOVFF 441,FEA
07D42: MOVFF 440,FE9
07D46: MOVF FEC,F
07D48: MOVF FEC,F
07D4A: RRCF FED,F
07D4C: RRCF FED,F
07D4E: RRCF FED,F
.................... // kaydırılmasında kullan.
.................... iterNum--;
07D50: MOVLB 4
07D52: DECF x42,F
07D54: BRA 7D20
.................... }
....................
.................... while(blankShiftNumber != 0)
07D56: MOVLB 0
07D58: MOVF xFB,F
07D5A: BZ 7D74
.................... {
.................... shift_right(ptr, 3, 0);
07D5C: MOVFF 441,FEA
07D60: MOVFF 440,FE9
07D64: MOVLW 02
07D66: ADDWF FE9,F
07D68: BCF FD8.0
07D6A: RRCF FED,F
07D6C: RRCF FED,F
07D6E: RRCF FED,F
.................... blankShiftNumber--;
07D70: DECF xFB,F
07D72: BRA 7D58
.................... }
....................
.................... inputRecordsStable[0] = 0;
07D74: CLRF xC8
.................... inputRecordsStable[1] = 0;
07D76: CLRF xC9
.................... inputRecordsStable[2] = 0;
07D78: CLRF xCA
....................
.................... return;
07D7A: RETURN 0
.................... }
.................... shift_right(ptr, 3, 0);
07D5C: MOVFF 441,FEA
07D60: MOVFF 440,FE9
07D64: MOVLW 02
07D66: ADDWF FE9,F
07D68: BCF FD8.0
07D6A: RRCF FED,F
07D6C: RRCF FED,F
07D6E: RRCF FED,F
shift_right(ptr, 3, shiftBit);
void ShiftToRecords(int8*, int8, int1);
so we are shifting 0xFE, 0xFF and 0x100
Yes, shift_right() doesn't work if the data entity crosses a page boundary.I think this is a compiler bug. What do you think?
006C 0E02 MOVLW 0x2
006E 26E9 ADDWF 0xfe9, F, ACCESS
0070 90D8 BCF 0xfd8, 0, ACCESS
0072 32ED RRCF 0xfed, F, ACCESS
0074 32ED RRCF 0xfed, F, ACCESS
0076 32ED RRCF 0xfed, F, ACCESS
Not right. A PIC18 pointer is a 16 bit entity, no matter what data size it points to. Similarly the index registers FSR0, FSR1 and FSR2 have a low and high byte. If you read the disassembly listing thoroughly, you'll see.0x100 is a two byte.
If ptr can only point to a byte.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?