This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to invoke arm cortex m3 pendsv handle

Note: This was originally posted on 4th September 2013 at http://forums.arm.com

I try to invoke pendsv handle after svc. I can enter svc_isr, but after exit svc_isr, can not enter pendsv_handle, direct go to deadloop.
Can not go to pendsv_handle.

dump 0xe000ed04

(gdb) x/1xw 0xe000ed04
0xe000ed04: 0x1080e000[size=2]
[/size][size=2]It looks good.[/size]
Any suggest? Thank you for your help.

environment:
gcc
stm32discovery board

my code:
# test pendSV handler

.equ STACK_TOP, 0x20000800
.text
.global _start
.code 16
.syntax unified
_start:
  .word STACK_TOP, start
  .type start, function @ let lsb to 1
  .word int_isr+1
  .word int_isr+1
  .word int_isr+1
  .word int_isr+1
  .word int_isr+1
  .word int_isr+1
  .word int_isr+1
  .word int_isr+1
  .word int_isr+1
  .word svc_isr+1 @ svc isr
  .word int_isr+1
  .word int_isr+1
  .word pendsv_handle+1
  .word int_isr+1
  .word int_isr+1
  .word int_isr+1
  .word int_isr+1

start:

@ ref: @ Cortex™-M3 Technical Reference Manual (file name: DDI0337E_cortex_m3_r1p1_trm.pdf)
@    System Handler Priority Registers (p8-27)
  @ pendsv priority
  ldr r0, =0xe000ed22
  mov r1, #0xff
  strb r1, [r0]

  @ systick priority
  ldr r0, =0xe000ed23
  mov r1, #0xff
  strb r1, [r0]

  @ svc priority
  ldr r0, =0xe000ed1f
  mov r1, #0xff
  strb r1, [r0]

  cpsie i

  svc 0

@ watch 0xe000ed24, 0xe000ed04 ref: arm cortex-m3: 嵌入式系統設計入門 p8-9

  push {r0}

deadloop:
  nop
  push {r0}
  b deadloop

pendsv_handle:
  movs r2, #0x12
  nop
  bx lr

svc_isr:
  @ enable pendsv ref: STM32F207 高性能网络型 MCU 嵌入式系统设计 p 412
  ldr r0, =0xe000ed04
  ldr r1, [r0]
  orr r1, #0x10000000
  str r1, [r0]
  nop
  movs r3, #0x56
  bx lr

int_isr:
  nop
  movs r1, #0xf
  push {r1}
  bx lr

.data
.space  0x200, 0
psp_stack_top:

.space  0x400, 0
msp_stack_top:
             

Parents
  • Note: This was originally posted on 4th September 2013 at http://forums.arm.com

    May be the PendSV priority is still same as SVC.
    To make sure please try with highest priority for PendSV and check
    ldr r0, =0xe000ed22
      mov r1, #0x00
      strb r1, [r0]
    It should work. You should able to invoke PendSV handler.
    Feel free to contact me further
    PendSV handler will be invoked after the execution of SVC handler (svc_isr) in your case even if the priorities are same.
    From the value of the register it looks the PendSV is already requested. Please read the status registers SHCSR and ICSR
Reply
  • Note: This was originally posted on 4th September 2013 at http://forums.arm.com

    May be the PendSV priority is still same as SVC.
    To make sure please try with highest priority for PendSV and check
    ldr r0, =0xe000ed22
      mov r1, #0x00
      strb r1, [r0]
    It should work. You should able to invoke PendSV handler.
    Feel free to contact me further
    PendSV handler will be invoked after the execution of SVC handler (svc_isr) in your case even if the priorities are same.
    From the value of the register it looks the PendSV is already requested. Please read the status registers SHCSR and ICSR
Children
No data