微處理器 - STMicroelectronics STM32F429 (STM32F429I-DISC1) - Assembly - Button



參考資訊:
https://www.st.com/resource/en/datasheet/dm00071990.pdf
https://www.st.com/resource/en/user_manual/dm00093903-discovery-kit-with-stm32f429zi-mcu-stmicroelectronics.pdf
https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405-415-stm32f407-417-stm32f427-437-and-stm32f429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf

Button測試使用B1 USER(PA-0)


GPIO-A Clock


Mode


Pull-up


Input


main.s

    .equiv PORTA_BASE,  0x40020000
    .equiv PORTG_BASE,  0x40021800
    .equiv GPIO_MODER,  0x0000
    .equiv GPIO_PUPDR,  0x000c
    .equiv GPIO_IDR,    0x0010
    .equiv GPIO_ODR,    0x0014

    .equiv RCC_BASE,    0x40023800 
    .equiv RCC_AHB1ENR, 0x0030

    .thumb
    .cpu cortex-m4
    .syntax unified

    .global _start

    .text
    .org 0x0000
_start:
    .word 0x20008000
    .word reset
 
    .org 0x0100
    .thumb_func
reset:
    ldr r0, =RCC_BASE
    ldr r1, [r0, #RCC_AHB1ENR]
    orr r1, #(1 << 6) | (1 << 0)
    str r1, [r0, #RCC_AHB1ENR]
 
    ldr r0, =PORTG_BASE
    ldr r1, =(1 << 26)
    str r1, [r0, #GPIO_MODER]
 
    ldr r0, =PORTA_BASE
    ldr r1, [r0, #GPIO_MODER]
    bic r1, #3
    str r1, [r0, #GPIO_MODER]
    ldr r1, [r0, #GPIO_PUPDR]
    bic r1, #3
    orr r1, #2
    str r1, [r0, #GPIO_PUPDR]
 
0:
    ldr r0, =PORTA_BASE
    ldr r1, [r0, #GPIO_IDR]
    lsl r1, #13
    ldr r0, =PORTG_BASE
    str r1, [r0, #GPIO_ODR]
    b 0b
    .end

完成