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

Why cortex m4 (stm32 discovery) usart3 is not working ??? (SOFTWARE)

Hello,

I have a problem,i wrote this program but it dosen't work.

It doesn't read its rx pin.

Can you help me pls ???

CODS:

PUBLIC MAINTASK
PUBLIC __vector_table
SECTION .text:CODE:REORDER(10)
;; Keep vector table even if it's not referenced
REQUIRE __vector_table
THUMB

BIT0 EQU 1 << 0
BIT1 EQU 1 << 1
BIT2 EQU 1 << 2
BIT3 EQU 1 << 3
BIT4 EQU 1 << 4
BIT5 EQU 1 << 5
BIT6 EQU 1 << 6
BIT7 EQU 1 << 7
BIT8 EQU 1 << 8
BIT9 EQU 1 << 9
BIT10 EQU 1 << 10
BIT11 EQU 1 << 11
BIT12 EQU 1 << 12
BIT13 EQU 1 << 13
BIT14 EQU 1 << 14
BIT15 EQU 1 << 15
BIT16 EQU 1 << 16
BIT17 EQU 1 << 17
BIT18 EQU 1 << 18
BIT19 EQU 1 << 19
BIT20 EQU 1 << 20
BIT21 EQU 1 << 21
BIT22 EQU 1 << 22
BIT23 EQU 1 << 23
BIT24 EQU 1 << 24
BIT25 EQU 1 << 25
BIT26 EQU 1 << 26
BIT27 EQU 1 << 27
BIT28 EQU 1 << 28
BIT29 EQU 1 << 29
BIT30 EQU 1 << 30
BIT31 EQU 1 << 31

RCC_BASE EQU 0x40023800
RCC_AHB1ENR EQU RCC_BASE + 0x30
RCC_APB1ENR EQU RCC_BASE + 0x40
RCC_CFGR EQU RCC_BASE + 0x08

GPIOD_BASE EQU 0x40020C00
GPIOD_MODER EQU GPIOD_BASE + 0x00
GPIOD_ODR EQU GPIOD_BASE + 0x14
GPIOD_IDR EQU GPIOD_BASE + 0x10
GPIOD_BSRR EQU GPIOD_BASE + 0x18
GPIOD_AFRH EQU GPIOD_BASE + 0x24

USART_SR EQU GPIOD_BASE + 0x00
USART_DR EQU GPIOD_BASE + 0x04
USART_BRR EQU GPIOD_BASE + 0x08
USART_CR1 EQU GPIOD_BASE + 0x0C

MAINTASK

LDR R0, =RCC_AHB1ENR 
LDR R1, [R0] 
ORR R1,R1,#BIT3
STR R1, [R0] 


LDR R0, =RCC_APB1ENR
LDR R1,[R0]
ORR R1,R1,#BIT18
str R1, [R0] 


LDR R0, =GPIOD_MODER 
LDR R1, =(BIT0|BIT2|BIT4|BIT6|BIT8|BIT10|BIT17|BIT19)
STR R1, [R0] 


LDR R0, =USART_CR1 
LDR R1, =(BIT13|BIT2|BIT3|BIT5) 
STR R1, [R0] 


LDR R0, =USART_BRR 
LDR R1, =0x341 ; BRAUD RATE 9600
STR R1, [R0] 

DATASTOCONTROL
LDR R2, =0x31 ;1 signal
LDR R3, =0x32 ;2 signal
LDR R4, =0x33 ;3 signal
LDR R5, =0x34 ;4 signal

CONTROLREAD


LDR R0, =USART_SR
LDR R1, [R0] 
MOVS R0, #BIT5 
TST R0, R1 
BEQ CONTROLREAD 


LDR R0, =USART_DR ; USART_DR(gelen veri) degerini R0'a yükle
LDR R1, [R0] ; USART_DR registerini R1'ye kopyala

MOVE


CMP R1, R2
BEQ FORWARD
CMP R1, R3
BEQ BACK
CMP R1, R4
BEQ RIGHT
CMP R1, R5
BEQ LEFT
BL CONTROLREAD


FORWARD
MOV R0,#0
MOV R1,#0
LDR R0,=GPIOD_ODR
MOV R1,#(BIT0|BIT2|BIT8|BIT10)
STR R1,[R0]
BL CONTROLREAD


BACK
MOV R0,#0
MOV R1,#0
LDR R0,=GPIOD_ODR
MOV R1,#(BIT4|BIT6|BIT8|BIT10)
STR R1,[R0]
BL CONTROLREAD


RIGHT
MOV R0,#0
MOV R1,#0
LDR R0,=GPIOD_ODR
MOV R1,#(BIT0|BIT6|BIT8|BIT10)
STR R1,[R0]
BL CONTROLREAD


LEFT
MOV R0,#0
MOV R1,#0
LDR R0,=GPIOD_ODR
MOV R1,#(BIT2|BIT4|BIT8|BIT10)
STR R1,[R0]
BL CONTROLREAD

;; Forward declaration of sections.

SECTION CSTACK:DATA:NOROOT(10)
SECTION .intvec:CODE:NOROOT(10)

DATA

__vector_table
DCD sfe(CSTACK)
DCD MAINTASK

DCD NMI_Handler
DCD HardFault_Handler
DCD MemManage_Handler
DCD BusFault_Handler
DCD UsageFault_Handler
DCD 0
DCD 0
DCD 0
DCD 0
DCD SVC_Handler
DCD DebugMon_Handler
DCD 0
DCD PendSV_Handler
DCD SysTick_Handler

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Default interrupt handlers.
;;

PUBWEAK NMI_Handler
PUBWEAK HardFault_Handler
PUBWEAK MemManage_Handler
PUBWEAK BusFault_Handler
PUBWEAK UsageFault_Handler
PUBWEAK SVC_Handler
PUBWEAK DebugMon_Handler
PUBWEAK PendSV_Handler
PUBWEAK SysTick_Handler

SECTION .text:CODE:REORDER:NOROOT(10)
THUMB

NMI_Handler
HardFault_Handler
MemManage_Handler
BusFault_Handler
UsageFault_Handler
SVC_Handler
DebugMon_Handler
PendSV_Handler
SysTick_Handler
Default_Handler
__default_handler
CALL_GRAPH_ROOT __default_handler, "interrupt"
NOCALL __default_handler
B __default_handler
BL MAINTASK
END

  • So what debugging have you done to find the problem?

    Have you tried working examples before leaping into swathes of unformatted, uncommented assembler?

    Have you done basics like blinking LEDs? 

    Can you transmit?

    Note that the USART has nothing to do with ARM - it is ST's proprietary IP - so you'd probably be better asking on the ST forum

    community.arm.com/.../158950

  • Have you done basics like blinking LEDs?  yes, i do 

    Note that the USART has nothing to do with ARM - it is ST's proprietary IP - so you'd probably be better asking on the ST forum 

    You are right , i am sorry for that.