2016-02-16 11:00 AM
Hi.
I encountered a problem where I use CRC hardware with optimized code in Keil. I use CRC hardware inside of interrupt routine and without optimization I get correct result. But if I turn optimization on (level 1 is enough) I don't get correct result anymore. Do you have any idea what could be wrong here?Before calculation (already inside of ISR) I reset CRC and then do 6 consecutive writes to DR register. First I write a half-word and after that five writes of a byte variable from an array. Then I store a result to new 8-bit variable:*(uint16_t *)&CRC->DR = half_word_var;*(uint8_t *)&CRC->DR = byte_array[0];*(uint8_t *)&CRC->DR = byte_array[1];*(uint8_t *)&CRC->DR = byte_array[2];*(uint8_t *)&CRC->DR = byte_array[3];*(uint8_t *)&CRC->DR = byte_array[4];*(uint8_t *)&CRC->DR = byte_array[5];byte_result = (uint8_t)CRC->DR;2016-02-23 11:54 PM
Aha, I misunderstood the situation then, sorry. In that case the casting is completely unnecessary, isn't it?
Some quotes from the RM0090 reference manual:''Each write operation into the data register creates a combination of the previous CRC value and the new one (CRC computation is done on the whole 32-bit data word, and not byte per byte).''
''The CRC registers have to be accessed by words (32 bits).''
2016-02-24 04:34 AM
Aha, I misunderstood the situation then, sorry. In that case the casting is completely unnecessary, isn't it?
While it's not conveyed here, the OP has an F3 or F0 part which has a more advanced CRC peripheral.In this case, as I recall, it's being set in an 8-bit mode and can then be feed bytes, half-words, and words.If the forum was not so awful you'd be able to click on the avatar and see the post history.I'd prefer it if people would keep one thread to discuss their project than keep forking threads and creating new ones about materially the same topic or progression of implementation and losing all the context.2016-02-24 01:18 PM