Hello,I'm using the soft-core Cortex-M0,and keil uvision 5, I have initialized the registers used for my ADDER : 0x59000000--->059FFFFFF and run simulation using vivado simulator when i tried that with assembly the simulaion worked correctly,but if i tried to add c code with the assembly it doesn't work: this the code: -----------------------------------------------------------------------------------------
; Vector Table Mapped to Address 0 at Reset PRESERVE8 THUMB AREA RESET, DATA, READONLY EXPORT __Vectors __Vectors DCD 0x0000FFFC DCD Reset_Handler DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 ; External Interrupts DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 DCD 0 AREA |.text|, CODE, READONLY ;Reset Handler Reset_Handler PROC GLOBAL Reset_Handler ENTRY IMPORT __main LDR R0, =__main BX R0 ENDP EXPORT func func FUNCTION ENDFUNC ALIGN 4 END
------------------------------------------------------------------------------------- and the code C :
#include <stdlib.h> #include <stdio.h> #include <rt_misc.h> #define AAA (*((volatile unsigned long *)(0x59000000UL))) extern void func_x() { unsigned int volatile * const port1 = (unsigned int *) AAA; int a = 0x11111111; *port1 = a; } int main(void) { func_x(); return 0; }
Your function 'func' has no code!
What the *$%$ do you think is going to execute when the C code jumps to it?
i tried that but it doesn't work
#define AAA 0x59000000 void func(){ *(unsigned int*)AAA=0x31 ; } int main(void) { func(); return 0;
func PROC BL func ENDP
What's with the recursion?
Why not try returning from func?
Hello, last yead,i'd the same error with simulation using vivado for expl,i remember,i did things like that: Reset_Handler PROC GLOBAL Reset_Handler ENTRY
IMPORT __main LDR R0, =__main BX R0
nd the main was:
#define AAA 0x59000000 int main(void) { *(unsigned int*)AAA=0x31 ; return 0; }
Consider using the debugger, turn off "run to main", and step through your code one instruction at a time until you understand what's wrong. Suggest a Hard Fault handler so you can see when it fails, and a routine for the other unused vectors to use instead of zero.
Make sure you have correctly defined the memory for the linker, and that your stack points to usable RAM.