Question
STM32F100 USART outputs 00
Posted on November 27, 2013 at 15:56
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 0x400138 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!
ldr r0, =0x40021000 ; RCC
ldr r1, =0x00004004 ; USART1EN | IOPAEN (GPIOA)
str r1, [r0, #0x18] ; RCC_APB2ENR
ldr r0, =0x40010800 ; GPIOA
ldr r1, =0x444444B4 ; PA.9 USART1_TX 50MHz AF_PP
str r1, [r0, #4] ; GPIOx_CRH
ldr r0, =0x40013800 ; UART1
movs r1, #0
strh r1, [r0, #4] ; +4 USART_DR
movs r1, #69 ; 8MHz / 69 == 115200
strh r1, [r0, #8] ; +8 USART_BR
movs r1, #0x0600
strh r1, [r0, #16] ; +16 USART_CR2 = 0x600
movs r1, #0
strh r1, [r0, #16] ; +16 USART_CR2 = 0
movs r1, #0
strh r1, [r0, #24] ; +24 USART_GTPR = 0 - Prescaler
movw r1, #0x200C ; 8-bit, no parity, enable TX,TX
strh r1, [r0, #12] ; +12 USART_CR1
ldr r2, =0x2000 ; Size = Length (8K)
ldr r3, =0x20000000 ; Mem = RAM Address
iu1 ldrh r1, [r0, #0] ; USART->SR
ands r1, #0x80 ; TXE
beq iu1
ldrb r1, [r3], #1 ; [Mem++]
strh r1, [r0, #4] ; USART->DR
subs r2, r2, #1 ; Size--
bne iu1
#usart #stm32-usart-data-register #stm32