cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401RE

CCV
Associate II
                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?
7 REPLIES 7
Issamos
Lead II

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

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

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

jokersD1
Associate

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

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

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

Hope this answers your question.

AREA mycode, CODE

EXPORT __main

myclock EQU 0x40023830

myDmode EQU 0x40020000

myDout EQU 0x40020014

myPU_PD EQU 0x4002080C

myPB4I EQU 0x40020810

myPC7O EQU 0x4002001C 

 

ENTRY

__main PROC

NOP

;------------------------------Port B Clock Enable for PB4

LDR R1,=myclock

LDR R5,[R1]

MOV R2,#1

LSL R2,#1 

ORR R5,R2

STR R5,[R1]

 

;------------------------------Port C Clock Enable for PC7

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 setup for PB4 (GPIOB)

LDR R1,=myclock

LDR R5,[R1]

MOV R2,#1

LSL R2,#1 

ORR R5,R2

STR R5,[R1]

 

;----------------------------Çikis uclari seçimi 

PC7 (GPIOC)

LDR R1,=myDmode

LDR R5,[R1]

MOV R2,#0x1

LSL R2,#14 

ORR R5,R2

STR R5,[R1]

 

;------------------------------Read PB4 pin

Re_PB4 LDR R1,=myPB4I

LDR R5,[R1]

MOV R2,#0x10 

AND R5,R2

CMP R5,#0

BEQ myRun

B Re_PB4

 

;----------------------------Led On 

myRun LDR R1,=myPC7O 

LDR R5,[R1]

MOV R2,#0x80 

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,=myPC7O 

LDR R5,[R1]

BIC R5,R2 

STR R5,[R1]

 

;------------------------

---- Gecikme 

LDR R6,=0XFFFFF

Two2 SUB R6,#1

CMP R6,#0

BEQ Re_PB4

B Two2

 

ENDP

END

 

Best regards.

II