AnsweredAssumed Answered

STM32F100 USART outputs 00

Question asked by schall.an on Nov 27, 2013
Latest reply on Dec 5, 2013 by Clive One
Hi together,

I am using the code below to iterate over SRAM and put out every byte over USART1. However, I am receiving only null-bytes. I was debugging the codein Keil MDK and everything seems to be fine except that when putting the value to be transmitted into USART1->DR the register seems to keep value 00 and does not hold the actual value (see line 37). THE USART1 data register is at 0x40013804. The code should be ok, maybe it is because of the wiring? I connected a FOCA break-out board to my STM32 (FOCA RX to PA9 STM, FOCA TX to PA10 STM, grnd to grnd, and vcc to 3.v STM).

Thanks in advance!

01.                ldr     r0, =0x40021000 ; RCC
02.  
03.                ldr     r1, =0x00004004 ; USART1EN | IOPAEN (GPIOA)
04.                str     r1, [r0, #0x18] ; RCC_APB2ENR
05.  
06.                ldr     r0, =0x40010800 ; GPIOA
07.  
08.                ldr     r1, =0x444444B4 ; PA.9 USART1_TX 50MHz AF_PP
09.                str     r1, [r0, #4]    ; GPIOx_CRH
10.  
11.                ldr     r0, =0x40013800 ; UART1
12.  
13.                movs    r1, #0
14.                strh    r1, [r0, #4]    ;  +4 USART_DR
15.  
16.                movs    r1, #69         ; 8MHz / 69 == 115200
17.                strh    r1, [r0, #8]    ;  +8 USART_BR
18.  
19.                movs    r1, #0x0600
20.                strh    r1, [r0, #16]   ; +16 USART_CR2 = 0x600
21.  
22.                movs    r1, #0
23.                strh    r1, [r0, #16]   ; +16 USART_CR2 = 0
24.  
25.                movs    r1, #0
26.                strh    r1, [r0, #24]   ; +24 USART_GTPR = 0 - Prescaler
27.  
28.                movw    r1, #0x200C     ; 8-bit, no parity, enable TX,TX
29.                strh    r1, [r0, #12]   ; +12 USART_CR1
30.  
31.                ldr     r2, =0x2000     ; Size = Length (8K)
32.                ldr     r3, =0x20000000 ; Mem = RAM Address
33.iu1             ldrh    r1, [r0, #0]    ; USART->SR
34.                ands    r1, #0x80       ; TXE
35.                beq     iu1
36.                ldrb    r1, [r3], #1    ; [Mem++]
37.                strh    r1, [r0, #4]    ; USART->DR
38.                subs    r2, r2, #1      ; Size--
39.                bne     iu1

Outcomes