We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
ePendSV_handler: mrs r0,PSP stmdb r0!,{r4-r11,lr}; ... load ... load new PSP valu here to R0 ldmia r0!,{r4-r11,lr} msr PSP,r0 bx lr void eSVCall(void){ unsigned int a0,a1,a2,a3,svc,*psp; psp=(U32*)__get_PSP(); a0=psp[0];a1=psp[1];a2=psp[2];a3=psp[3]; //get registers from user stack svc=psp[4]; // service call ID a0=service(svc,a0,a1,a2,a3); psp[0]=a0; //overwrite R0(return value) in user stack} SVC usage in thread level code: mov R12, #1 ; service call ID mov R0, #123 ; arg svc #0 ; now R0 holds return value
__svc(42) void svc00(void); SCB->SHPR[11-4]=0xF0; // system handler 11, SVCall SCB->SHPR[14-4]=0xF0; // system handler 14, PendSV __cpsie_i(); SCB->ICSR=SCB_ICSR_PENDSVSET; svc00(); while(1);ePendSV bx lreSVCall bx lr
SCB->ICSR=SCB_ICSR_PENDSVSET; __DSB(); __ISB(); svc00();