Tool/software: TI C/C++ Compiler
I have a simple question, My program is trapped at Fault ISR,
Below is my code that is trapped at Fault ISR
int writeProgMemoryBlock(const unsigned char *data, uint16_t dataSize, uint8_t bank, uint8_t address, int verify) { //return writeMemoryBlock(data, dataSize, bank, address, verify, 1); setMemoryBank(bank,0,0); setMemoryStartAddress(address); uint8_t chunkSize; uint8_t *verifyBuffer; uint8_t *progBuffer; uint16_t i; uint8_t j; if (verify) verifyBuffer = (uint8_t *)malloc(MPU6050_DMP_MEMORY_CHUNK_SIZE); if (1) progBuffer = (uint8_t *)malloc(MPU6050_DMP_MEMORY_CHUNK_SIZE); for (i = 0; i < dataSize;) { // determine correct chunk size according to bank position and data size chunkSize = MPU6050_DMP_MEMORY_CHUNK_SIZE; // make sure we don't go past the data size if (i + chunkSize > dataSize) chunkSize = dataSize - i; // make sure this chunk doesn't go past the bank boundary (256 bytes) if (chunkSize > 256 - address) chunkSize = 256 - address; if (1) { // write the chunk of data as specified for (j = 0; j < chunkSize; j++) progBuffer[j] = pgm_read_byte(data + i + j); } else { // write the chunk of data as specified progBuffer = (uint8_t *)data + i; } for (i = 0; 0 < chunkSize; i++){ writeByte(devAddr, MPU6050_RA_MEM_R_W, progBuffer[i]); } // verify data if needed if (verify && verifyBuffer) { setMemoryBank(bank,0,0); setMemoryStartAddress(address); readBytes(devAddr, MPU6050_RA_MEM_R_W, chunkSize, verifyBuffer); if (memcmp(progBuffer, verifyBuffer, chunkSize) != 0) { free(verifyBuffer); if (1) free(progBuffer); return false; // uh oh. } } // increase byte index by [chunkSize] i += chunkSize; // uint8_t automatically wraps to 0 at 256 address += chunkSize; // if we aren't done, update bank (if necessary) and address if (i < dataSize) { if (address == 0) bank++; setMemoryBank(bank,0,0); setMemoryStartAddress(address); } } if (verify) free(verifyBuffer); if (1) free(progBuffer); return true; }
When I try to debug to go into the this function, it jumps into FaultISR function.
How to figure out the reason and solution of the problem?
I use code composer studio with TM4C123. I am trying to read quaternion values from MPU6050. I finished my code but I couldn't finalize my project.
Thanks in advance