1
\$\begingroup\$

I want to initialize and use UART on my LM4F120 Stellaris Launchpad in ASM. I found a reference code on how to to this on this site.

This works fine, however it initializes and uses UART0 (which is emulated over USB). I need to employ UART using the PIN headers. Thus, I want to use UART1 over PC0 (Rx) / PC1(Tx) following the convention in table 2-3 form this manual:

Basically, I changed the constant values to:

NVIC_EN0_INT5      EQU 0x00000020   ; Interrupt 5 enable
NVIC_EN0_R         EQU 0xE000E100   ; IRQ 0 to 31 Set Enable Register
NVIC_PRI1_R        EQU 0xE000E404   ; IRQ 4 to 7 Priority Register
GPIO_PORTB_AFSEL_R EQU 0x40005420
GPIO_PORTB_DEN_R   EQU 0x4000551C
GPIO_PORTB_AMSEL_R EQU 0x40005528
GPIO_PORTB_PCTL_R  EQU 0x4000552C
UART1_DR_R         EQU 0x4000D000
UART1_FR_R         EQU 0x4000D018
UART1_IBRD_R       EQU 0x4000D024
UART1_FBRD_R       EQU 0x4000D028
UART1_LCRH_R       EQU 0x4000D02C
UART1_CTL_R        EQU 0x4000D030
UART1_IFLS_R       EQU 0x4000D034
UART1_IM_R         EQU 0x4000D038
UART1_RIS_R        EQU 0x4000D03C
UART1_ICR_R        EQU 0x4000D044
UART_FR_RXFF       EQU 0x00000040   ; UART Receive FIFO Full
UART_FR_TXFF       EQU 0x00000020   ; UART Transmit FIFO Full
UART_FR_RXFE       EQU 0x00000010   ; UART Receive FIFO Empty
UART_LCRH_WLEN_8   EQU 0x00000060   ; 8 bit word length
UART_LCRH_FEN      EQU 0x00000010   ; UART Enable FIFOs
UART_CTL_UARTEN    EQU 0x00000001   ; UART Enable
UART_IFLS_RX1_8    EQU 0x00000000   ; RX FIFO >= 1/8 full
UART_IFLS_TX1_8    EQU 0x00000000   ; TX FIFO <= 1/8 full
UART_IM_RTIM       EQU 0x00000040   ; UART Receive Time-Out Interrupt
                                    ; Mask
UART_IM_TXIM       EQU 0x00000020   ; UART Transmit Interrupt Mask
UART_IM_RXIM       EQU 0x00000010   ; UART Receive Interrupt Mask
UART_RIS_RTRIS     EQU 0x00000040   ; UART Receive Time-Out Raw
                                    ; Interrupt Status
UART_RIS_TXRIS     EQU 0x00000020   ; UART Transmit Raw Interrupt
                                    ; Status
UART_RIS_RXRIS     EQU 0x00000010   ; UART Receive Raw Interrupt
                                    ; Status
UART_ICR_RTIC      EQU 0x00000040   ; Receive Time-Out Interrupt Clear
UART_ICR_TXIC      EQU 0x00000020   ; Transmit Interrupt Clear
UART_ICR_RXIC      EQU 0x00000010   ; Receive Interrupt Clear
SYSCTL_RCGC1_R     EQU 0x400FE104
SYSCTL_RCGC2_R     EQU 0x400FE108
SYSCTL_RCGC1_UART1 EQU 0x00000002   ; UART1 Clock Gating Control
SYSCTL_RCGC2_GPIOA EQU 0x00000002   ; port A Clock Gating Control

However, I can not receive any characters on the virtual com port. Do you see any mistakes in the code?

\$\endgroup\$
  • \$\begingroup\$ Have you meassured the lines instead of just seing if you can "receive characters"? \$\endgroup\$ – chwi Nov 26 '13 at 19:31
  • \$\begingroup\$ Why assembly? Also you are mentioning UART over USB. Do you have some kind of USB CDC routines in your embedded code? \$\endgroup\$ – Maciej Kucia Nov 27 '13 at 8:59
  • \$\begingroup\$ I did not measure the lines because of lack of decent hardware. ASM because this code will run before main() is called. USB CDC routines? Well UART over USB works fine (UART0). However, I want to use the onboard PIN headers (UART1/2). \$\endgroup\$ – Richard Laurant Nov 28 '13 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.