2018-09-12 12:31 AM
i use NUCLEO - F767ZI and test a simple code as follow
int sum(int a,int b){
return a+b;
}
int main(void){
int dly;
__enable_irq();
SysTick_Config(100000);
NVIC_EnableIRQ(SysTick_IRQn);
dly = sum(1,3);
return 0;
}
i debug it and when call sum(1,3), it will goto hard fault.
if comment NVIC_EnableIRQ(SysTick_IRQn); call and it work fine.
can someone help me ?
2018-09-12 12:43 AM
I don't think you are supposed to return from main().
JW
2018-09-12 12:47 AM
this is example code,actually ,if call NVIC_EnableIRQ(SysTick_IRQn); it will goto hard fault before return;
2018-09-12 01:03 AM
Do you have an interrupt handler routine for SysTick, don't you ?
And you have checked in the Map file, or ?
2018-09-12 01:35 AM
yes,i'm sure SysTick_Handler define correctly
2018-09-12 01:45 AM
And implemented + placed correctly ?
2018-09-12 02:50 AM
yes ,map like
i.SysTick_Handler 0x08000254 Section 0 main.o(i.SysTick_Handler)
i.SystemInit 0x08000258 Section 0 system_stm32f7xx.o(i.SystemInit)
i.__scatterload_copy 0x080002bc Section 14 handlers.o(i.__scatterload_copy)
i.__scatterload_null 0x080002ca Section 2 handlers.o(i.__scatterload_null)
i.__scatterload_zeroinit 0x080002cc Section 14 handlers.o(i.__scatterload_zeroinit)
i.main 0x080002dc Section 0 main.o(i.main)
i.sum 0x08000358 Section 0 main.o(i.sum)
i think it not about SysTick_Handler, because it goto hard fault before call sum(...)
2018-09-12 03:14 AM
And did you evaluate the hardfault reason (SCB regs) ?
2018-09-12 05:59 AM
Really shouldn't need to do that, if you've configured the SysTick it should have the SCB set up.
Remember it is a System Handler, not an IRQ in the broader sense, and the IRQn will be negative
HAL_NVIC_SetPriority() would be usable
2018-09-12 10:29 AM
How big is the stack and is it defined within reachable RAM? Are other interrupts working well?
Is the VTOR modified in start-up code? It must be aligned or else HF will occur, too.