Skip to main content
Visitor II
September 2, 2023
Question

STM32F401RE

  • September 2, 2023
  • 2 replies
  • 2139 views
                AREA mycode, CODE
EXPORT __main
myclock EQU 0x40023830
myDmode EQU 0x40020000
myDout EQU 0x40020014
myPU_PD EQU     0x4002080C
myPC13I EQU     0x40020810
ENTRY
__main PROC
NOP
;------------------------------Port C Clock Enable
LDR R1,=myclock
LDR R5,[R1]
MOV R2,#1
LSL R2,#2
ORR R5,R2
STR R5,[R1]
;------------------------------PC13 Pull-Up Pull-Down
LDR R1,=myPU_PD
LDR R5,[R1]
MOV R2,#1
LSL R2,#26
ORR R5,R2
STR R5,[R1]
 
;---------------------------Clock PA5 LED, PC13 User Button
LDR R1,=myclock
LDR R5,[R1]
MOV R2,#1
LSL R2,#0
ORR R5,R2
STR R5,[R1]
;----------------------------Chose output PA5
LDR R1,=myDmode
LDR R5,[R1]
MOV R2,#0x1
LSL R2,#10
ORR R5,R2
STR R5,[R1]
;------------------------------Read PC13 pin
Re_PC13 LDR R1,=myPC13I
    LDR R5,[R1]
MOV R2,#0x2000
AND R5,R2
CMP R5,#0
BEQ myRun
B Re_PC13
;----------------------------Led On
myRun NOP
One2 LDR R1,=myDout
LDR R5,[R1]
;MOV R2,#0xF
MOV R2,#0x1
;LSL R2,#12
LSL R2,#5
ORR R5,R2
STR R5,[R1]
;---------------------------- LATE
LDR R6,=0XFFFFF
Two1 SUB R6,#1
CMP R6,#0
BEQ One1
B Two1
;---------------------------- LED off
One1 LDR R1,=myDout
LDR R5,[R1]
LDR R2,=0xFFFFFFCF
AND R5,R2
STR R5,[R1]
;---------------------------- LATE
LDR R6,=0XFFFFF
Two2 SUB R6,#1
CMP R6,#0
BEQ Re_PC13
B Two2
;----------------------------
ENDP
END
 
 
 
How can I configure PA4 pin Input and PC7 pin Output on this program.Im using STM32F401RE microcontroller card. Can you help me?
    This topic has been closed for replies.

    2 replies

    Graduate II
    September 2, 2023

    Hello @CCV 

    I think that you are programming Using assembly. I suggest you to watch this video that shows you how to program an STM32 using assembly language.

    Also, you can open an exemple of code in C that do the same thing and then open the Disassembly View which is well described in this post. This view will give a transaction of the C code to assembly language. Then you can copie the assembly code to your project .

    Hope this is helpful. If your question is answered please check this answer as best answer to be diffused.

    Best regards.

    II

    CCVAuthor
    Visitor II
    September 2, 2023

    I watched this video but I didn't , if you know can you do this for me

    Graduate II
    September 2, 2023

    Try this

    • Configure PA4 as an input: 

    LDR R1,=myDmode

    LDR R5,[R1]

    MOV R2,#0x00 

    LSL R2,#8 

    ORR R5,R2

    STR R5,[R1]

    • Configure PC7 as an output:

    LDR R1,=myDmode

    LDR R5,[R1]

    MOV R2,#0x01 

    LSL R2,#28 

    ORR R5,R2

    STR R5,[R1]

    I think you should do a test I'm not 100% sure. 

    Best regards

    II

    Visitor II
    September 6, 2023

    Likewise, I need to change the inputs and outputs in this code. Can anyone help?

    Graduate II
    September 6, 2023

    Hello @jokersD1 

    I suggest you to answer your questions in a new post to give it more visibility. Also, you have to give more details about what you exactly want to do.

    Best regards.

    II

    Visitor II
    September 6, 2023

    Hello, I have NUCLEON STM32 F401RE Model, I want to replace the input pin with pb4 instead of pc13 and the output pin with pc7 instead of pa5 in the program I threw. I looked at the datasheet, but I couldn't understand it, can you help ?

    ///CODE///

    AREA mycode, CODE
    EXPORT __main
    myclock EQU 0x40023830
    myDmode EQU 0x40020000
    myDout EQU 0x40020014
    myPU_PD EQU     0x4002080C
    myPC13I EQU     0x40020810
    ENTRY
    __main PROC
    NOP
    ;------------------------------Port C Clock Enable
    LDR R1,=myclock
    LDR R5,[R1]
    MOV R2,#1
    LSL R2,#2
    ORR R5,R2
    STR R5,[R1]
    ;------------------------------PC13 Pull-Up Pull-Down
    LDR R1,=myPU_PD
    LDR R5,[R1]
    MOV R2,#1
    LSL R2,#26
    ORR R5,R2
    STR R5,[R1]
     
    ;---------------------------Clock uygulamaPA5 LED, PC13 User Button
    LDR R1,=myclock
    LDR R5,[R1]
    MOV R2,#1
    LSL R2,#0
    ORR R5,R2
    STR R5,[R1]
    ;----------------------------Çikis uclari seçimi PA5
    LDR R1,=myDmode
    LDR R5,[R1]
    MOV R2,#0x1
    LSL R2,#10
    ORR R5,R2
    STR R5,[R1]
    ;------------------------------Read PC13 pin
    Re_PC13 LDR R1,=myPC13I
        LDR R5,[R1]
    MOV R2,#0x2000
    AND R5,R2
    CMP R5,#0
    BEQ myRun
    B Re_PC13
    ;----------------------------Led On
    myRun NOP
    One2 LDR R1,=myDout
    LDR R5,[R1]
    ;MOV R2,#0xF
     
    ;LSL R2,#12
    LSL R2,#5
    ORR R5,R2
    STR R5,[R1]
    ;---------------------------- Gecikme
    LDR R6,=0XFFFFF
    Two1 SUB R6,#1
    CMP R6,#0
    BEQ One1
    B Two1
    ;---------------------------- LED off
    One1 LDR R1,=myDout
    LDR R5,[R1]
    LDR R2,=0xFFFFFFCF
    AND R5,R2
    STR R5,[R1]
    ;---------------------------- Gecikme
    LDR R6,=0XFFFFF
    Two2 SUB R6,#1
    CMP R6,#0
    BEQ Re_PC13
    B Two2
    ;----------------------------
    ENDP
    END