I am working RL78D1A controller (R5F10 DMJ). while running this below code controller is getting reset due to RAM parity error. The controller is resetting after k = 0x4821. RPEF bit in the RPECTL register is 0x01. If i execute step by step after k = 0x4820 RAM parity error is not coming. Please let me know the solution for this.
uint16_t crc16( uint8_t *data, uint32_t length) { uint16_t crc = INIT_CRC; uint16_t i = 0; uint8_t j = 0; //uint32_t K = 0; uint16_t crc_entry; // Generate the CRC lookup table if (!crc_table[1]) { for ( i = 0; i < 256; i++) { crc_entry = i << 8; for (j = 0; j < 8; j++) { crc_entry = (crc_entry & 0x8000) ? (crc_entry << 1) ^ POLY : crc_entry << 1; } crc_table[i] = crc_entry; } }
for (K = 0; K < length; K++) { crc = (crc << 8) ^ crc_table[(crc >> 8) ^ data[K]];
if(K == 0x4820) { NOP(); NOP(); } if(RPECTL&0x01) { NOP(); NOP(); }
}
return crc;}
Hello,
Do you want the RAM parity error to not cause a reset or to not happen at all ?
Regards
I want to reset if there is a RAM parity error. But I want to know why it is causing RAM parity error. and how to solve that.
It is possibly an issue of RAM initialization. During startup some parts of RAM (.bss, .dataR , stack sections) are initialized but other do not. As a result there are uninitialized parts in RAM that can cause RAM parity errors.
I am currently working on the best way to initialize RAM. Just a question: Which compiler are you using ? Is it CC-RL ?
Based a few assumptions, here is how I would restructure the code that you presented.
#define MAGIC_NUMBER_1 (256) // comment on this number! #define MAGIC_NUMBER_2 (8) // comment on this number! #define CRC_TABLE_SIZE (?) // assumed known size static uint16_t crc_table[CRC_TABLE_SIZE]; /*-----------------------------------------------*/ void CrcTblInit(void) { // Generate the CRC lookup table uint16_t i; for ( i = 0; i < MAGIC_NUMBER_1; i++) { uint16_t crc_entry = i << 8; uint8_t j; for (j = 0; j < MAGIC_NUMBER_2; j++) { crc_entry = (crc_entry & 0x8000) ? (crc_entry << 1) ^ POLY : crc_entry << 1; } crc_table[i] = crc_entry; } } /*-----------------------------------------------*/ uint16_t crc16( uint8_t *data, uint32_t length) { uint16_t crc = INIT_CRC; uint32_t K; for (K = 0; K < length; K++) { uint16_t CrcIdx = (crc >> 8) ^ data[K]; // ensure no out of bounds table access!!! if (CrcIdx > CRC_TABLE_SIZE) { HaltOutOfBoundsError(); } crc = (crc << 8) ^ crc_table[CrcIdx]; if(K == 0x4820) { NOP(); NOP(); } if(RPECTL&0x01) { NOP(); NOP(); } } return crc; } /*-----------------------------------------------*/
I would guess that your array index into the CRC-table is extending beyond the array bounds of the table, which might be uninitialized RAM area. Initializing the RAM at startup may mask the problem for now, but as soon as that RAM is allocated to something else, that mask turns into data corruption that becomes difficult to diagnose without data trace available.
CCRL
Thanks for your suggestion.
Please try to initialize RAM directly before the stack initialization in the cstart.asm file like below.
cstart.zip
The RAM start address and size are according to:
Hope it helps.
Thanks. It is working.