<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Receiving then transmitting from keyboard input</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/32839/receiving-then-transmitting-from-keyboard-input</link><description> 
 I have this code that needs modifying to be able to accept a
keyboard input and then transmit to serial window UART #1, 2 or 3 by
creating a loop that receives from UART 1 then Transmit to UART 1. I
am a little perplexed on how to begin this code because</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Receiving then transmitting from keyboard input</title><link>https://community.arm.com/thread/82877?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2015 18:17:28 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d2f031bc-dd6a-4b49-8c02-ab821fef2a99</guid><dc:creator>Steven W</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;b&gt;Ok, so far I have the following code, but still unable to see
any results in serial window uart #1 or #2. I am also unable to type
any characters in either of the mentioned windows.&lt;br /&gt;
so even if the code was incorrect, how do I fix the problem of being
able to type characters in the uart windows? I can get the cursor to
flash in the windows but it does not receive any texts from the
keyboard.&lt;/b&gt;&lt;/p&gt;

&lt;pre&gt;
; modified UART code for LPC2104 from Hohl and Hinds, Section 16.2.5
;   The modifications are to use push/pop instead of stmia/ldmdb

        area uartdemo, code, readonly
pinsel0  equ  0xe002C000        ; controls function of pins
u1start  equ  0xE0010000        ; start of UART1 registers


lcr0  equ  0xC          ; line control register for UART0
lsr0  equ  0x14         ; line status register for UART0
ramstart  equ  0x40000000       ; start of onboard RAM for 2104
stackstart  equ  0x40000200  ; start of stack

        entry

start
        ldr sp, = stackstart    ; set up stack pointer
        bl UARTConfig   ; initialize/configure UART0
        ;
go_again
        bl Transmit
        bl send
        bl go_again
;loop
        ;ldrb r0, [r1], #1      ; load character, increment address
        ;cmp r0, #0             ; null terminated?
        ;blne Transmit          ; send character to UART
        ;bne loop               ; continue if not a &amp;#39;0&amp;#39;
;done   b done                  ; otherwise, we are done

; subroutine UARTConfig
;   Configures the I/O pins first.
;   Then sets up the UART control register.
;   Parameters set to 8 bits, no parity, and 1 stop bit.
;   Registers used:
;   r5 - scratch register
;   r6 - scratch register
;   inputs:  none
;   outputs:  none

UARTConfig
        push {r5, r6, lr}
        ldr r5, = pinsel0       ; base address of register
        ldr r6, [r5]            ; get contents
        bic r6, r6, #0xF0000            ; clear out lower nibble
        bic r6, r6, #0x0000F            ; clear out lower nibble
        orr r6, r6, #0x50000    ; sets P0.8 and P0.9
        orr r6, r6, #0x00005    ; sets P0.0 to Tx0 and P0.1 to Rx0
        str r6, [r5]            ; r/modify/w back to register
        ldr r5, = u1start
        mov r6, #0x83           ; set 8 bits, no parity, 1 stop bit
        strb r6, [r5, #lcr0]    ; write control byte to LCR
        mov r6, #0x61           ; 9600 baud @ 15MHz VPB clock
        strb r6, [r5]           ; store control byte
        mov r6, #3              ; set DLAB = 0
        strb r6, [r5, #lcr0]    ; Tx and Rx buffers set up
        pop {r5, r6, pc}

; subroutine Transmit
;   Puts one byte into the UART for transmitting
;   Registers used:
;   r5 - scratch register
;   r6 - scratch register
;   inputs:  r0 - byte to transmit
;   outputs:  none

Transmit
        push {r5, r6, lr}
        ldr r5, = u1start

send
                ldr r5, = u1start
                LDRB r6, [r5, #lsr0]
                tst      r0, #0x5f
                beq wait
                LDRB r0, [r5]
                ;LDR r5,=u1start


wait    ldrb r6, [r5, #lsr0]    ; get status of buffer
                tst r6, #0x20           ; buffer empty?
                beq wait                ; spin until buffer is empty
                strb r0, [r5]
                pop {r5, r6, pc}
                b       Transmit





        end
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving then transmitting from keyboard input</title><link>https://community.arm.com/thread/69402?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 11:59:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fdb0e8ca-03b4-47c8-b906-084565291a46</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
So start with a loop.&lt;br /&gt;
Not too hard to implement.&lt;br /&gt;
Expand the loop to check if there are any incoming data from any UART
to pick up and place in a receive buffer.&lt;br /&gt;
Expand the loop to check if there are any buffered data that should
be sent to any UART - and if that UART is ready to accept more.&lt;br /&gt;
Expand the loop to scan a keyboard, and if a key is detected store in
a receive buffer.&lt;/p&gt;

&lt;p&gt;
What exact problems do you see with implementing a basic program
skeleton and then add features one at a time? All software is created
by the creation of individual blocks that are merged into larger and
larger programs - or maybe into macro-blocks that are then merged
into the program. So it&amp;#39;s similar to running a marathon - you do it
one step at a time.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>