2023-09-03 10:30 AM - edited 2023-09-03 10:31 AM
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 uygulama PA5 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
MOV R2,#0x1
;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
I have a STM32F401RE . I have PA4 pin Input and PC7 pin Output. I need help. I need PA4 offset and PC7 offset. Can you rewrite the program using the new inputs and outputs?
2023-09-03 10:55 AM
Hello @CCV
This is a modified version of your code:
AREA mycode, CODE
EXPORT __main
myclock EQU 0x40023830
myDmode EQU 0x40020000
myDout EQU 0x40020014
myPU_PD EQU 0x4002080C
myPC4I EQU 0x40020810 ; PA4 as Input
myPC7O EQU 0x40020C14 ; PC7 as Output
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]
;------------------------------PC4 Pull-Up Pull-Down
LDR R1,=myPU_PD
LDR R5,[R1]
MOV R2,#1
LSL R2,#4
ORR R5,R2
STR R5,[R1]
;---------------------------Clock uygulama PA5 LED, PC7 Output
LDR R1,=myclock
LDR R5,[R1]
MOV R2,#1
LSL R2,#0
ORR R5,R2
STR R5,[R1]
;----------------------------Çikis uclari seçimi PC7 (0100)
LDR R1,=myDmode
LDR R5,[R1]
MOV R2,#0x4
LSL R2,#28
ORR R5,R2
STR R5,[R1]
;------------------------------Read PA4 pin
Re_PA4 LDR R1,=myPC4I
LDR R5,[R1]
MOV R2,#0x10
AND R5,R2
CMP R5,#0
BEQ myRun
B Re_PA4
;----------------------------Led On (PC7 High)
myRun LDR R1,=myDout
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 (PC7 Low)
One1 LDR R1,=myDout
LDR R5,[R1]
MOV R2,#0xFFFFFF7F
AND R5,R2
STR R5,[R1]
;---------------------------- Gecikme
LDR R6,=0XFFFFF
Two2 SUB R6,#1
CMP R6,#0
BEQ Re_PA4
B Two2
ENDP
END
Hope this is helpful. If your question is answered please check this answer as best answer to be diffused.
Best regards.
II
2023-09-04 03:56 AM
Sorry its doesnt work
2023-09-04 04:09 AM
Hello again
Then, 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 and use it in your project .
Hope this is helpful. If your question is answered please check this answer as best answer to be diffused.
Best regards.
II