Hey everyone,
Just started using pointers , here is my code which is getting an error I will display after.
This is a global function I have created which causes the error:
void mk7sixt() {
if (sMode == 1 && m_sys == 1 && m_vs1 == 0) {pBit = &m_sixt1;}
}
However the compiler says the error happens when it is called in the Setup() area here:
byteVal = 0;
for (int i=3; i>=0; i--) {
bitWrite(byteVal, i, shiftdata0[i]);
if (i == 0) {
svalueI = fourPos(byteVal);
paramList[3] = svalueI;
if (syAorM == 1) {
mk7sixt(); //<-- THIS IS WHERE THE FUNCTION IS CALLED (line 422)
bitClear(*pBit, 3);
if(svalueI == 0) {
} else {
bitSet(*pBit, 3);
}
}
}
}
And here is the error:
sketch\C-MKS7-d-July5.ino.cpp.o: In function
setup':** **C:\Users\dmorr\Documents\arudino projekts\C-MKS7-d-July5/Setup.ino:422:(.text.setup+0xd5a): relocation truncated to fit: R_AVR_7_PCREL against
no symbol'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board ATmega1284.
The goal of this mk7sixt() function is to simply change the address of the pointer pBit so the bitclear/bitset operations execute on different variables, depending on those conditions. You might be wondering why I am calling a function with only one if-statement, well there were lots of if-statements in the function originally, but even with just one if-statement I still get this error, so something about the way of assigning this pointer an address is causing problems (i think?? ), but I have no idea why. All variables are byte types and all variables are global, so there shouldn't be any scope issues... Any insight would be greatly greatly appreciate, thank you!