Question
Why this pity code at line 13 couse the Hard Fault?
#include "stm32f0xx.h"
void SysInit(void);
uint8_t array1[260] = {0};
uint8_t array2[260] = {0};
uint16_t test;
int main(void) {
SysInit();
for(uint16_t i = 0; i < 260; i++)
array1[i] = i & 0xFF;
test = *(uint16_t*)&array1[0xEA];
test = *(uint16_t*)&array1[0xEC];
test = *(uint16_t*)&array1[0xEB];
while(1);
}
void SysInit(void) {
FLASH->ACR |= FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY;
RCC->CR2 |= RCC_CR2_HSI48ON;
while(!(RCC->CR2 & RCC_CR2_HSI48RDY)) {};
RCC->CFGR &= ~(RCC_CFGR_PPRE | RCC_CFGR_HPRE | RCC_CFGR_SW);
RCC->CFGR |= RCC_CFGR_PPRE_DIV16 | RCC_CFGR_HPRE_DIV1 | RCC_CFGR_SW_HSI48;
while((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI48) {};
RCC->CFGR &= ~RCC_CFGR_PPRE;
RCC->CFGR |= RCC_CFGR_PPRE_DIV1;
SystemCoreClockUpdate();
}Every other valid reading from the filed array1 works normaly (Except Index 0xEB). I tried almost everthing. (volatile, optimizer, additional variables, memory aglin etc.) This code works propely on other arm devices. I need this code for further purpose (writing to TX-SPI 16bit register).
MCU: STM32F072CBT
IDE: STM32CubeIDE, Keil
