EASy68K
http://www.easy68k.com/EASy68Kforum/

NEED HELP ON A LAB!
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1011
Page 1 of 1

Author:  mrpacijr [ Tue Apr 26, 2011 10:38 pm ]
Post subject:  NEED HELP ON A LAB!

I have a lab to create for school. The tasks are:

-Prompt an operator to input a series of characters, up to 160 (sentence,quote)...this should show up in Terminal
-Hit Enter on the keypad and the text should print to the LCD, a character at a time (.5 second delay).
-Only 20 characters per line, 4 lines total
-If inputed text is larger than 80 characters...it should display first 80, delay, clear and display the remaining characters.

This is what I have so far, basically the beginning of what the Professor started us with (2 subroutines):

STATREGR EQU $010002
XMIT EQU $010000
CR EQU $0D
LF EQU $0A
ST EQU $00
STATREGT EQU $010003
RECREG EQU $010001
INPORT EQU $020001
OUTPORT EQU $020001
ORG $1000
START:











**********************************************************************
SUBRTNE1:
MOVE.L #MESSAGE,A1 ;first instruction of program
WAIT MOVE.W STATREGR,D1 ;test TDRE bit 3 of STATREGR
AND.W #0008,D1 ;transmit data register empty?
BEQ WAIT
MOVE.W (A1)+,D0
ROL.W #8,D0
MOVE.B D0,XMIT ;sends a character
ROL.W #8,D0
WAIT1 MOVE.W STATREGR,D1 ;test TDRE bit 3 of stareg
AND.W #0008,D1
BEQ WAIT1
MOVE.B D0,XMIT ;sends another character
BNE WAIT ;checks for the st = string terminator

TRAP #14

* Variables and Strings

MESSAGE DC.B 'Hello, World! This is DE-1.',CR,CR,LF,LF,ST,ST

**********************************************************************
SUBRTNE2:
CLR.L D1
GETCH: BTST.B #0,STATREGT ; Test the RDRF bit to see if a character is in the UART waiting for de-serilization of the incoming bit stream

BEQ.S GETCH ; Branch back until Receive Data Register is full
MOVE.B RECREG,D1 ; Character received and placed into D1
AND.B #$7F,D1 ; Mask off the parity bit so that it is just ASCII
MOVE.B D1,OUTPORT ; Write the byte to the LED readout displays
BRA START ; Just do it again and again

END START ; last line of source

Author:  clive [ Wed Apr 27, 2011 12:26 am ]
Post subject: 

Well that code isn't going to get you far, they aren't real standalone subroutines (they don't return), one for outputting a string to a serial port, and another to read a character from a serial port and stick it into an LED register.

You're going to have to find some more information about your board, we have no idea from your post about the board you are using, it's peripherals, how to communicate with the LCD (presumably an 40x4 type display at a guess). What documentation do you have for the board?

Start by building your own routines to input the string from the serial port, echoing back each character until you get a RETURN/ENTER.

You will need to modify and complete the two subroutines you have to be more general getchar and putchar type functions.

You will need to create some routines to clear, navigate and print data to the LCD.

Author:  clive [ Wed Apr 27, 2011 1:41 am ]
Post subject: 

Is your board a softcore 68K running on an Altera board?

Based on a quick analysis of provided code, haven't test
Code:
**********************************************************************
* Clive's Simple Board Support Package for the ????
**********************************************************************

CR      EQU     $0D             ; Carriage Return
LF      EQU     $0A             ; Line Feed

                                ; UART Model?
XMIT    EQU     $010000         ; UART Transmit Register
RECREG  EQU     $010001         ; UART Receive Register
STATREG EQU     $010003         ; UART Status Register

INPORT  EQU     $020001         ; 8 Switches/Buttons?
OUTPORT EQU     $020001         ; 8 LEDs

        ORG     $1000
START:

        LEA     MESSAGE,A0      ; Address of message string
        BSR     PUTS

ECHO    BSR     GETCH           ; Echo back serial input until CR or LF
        CMP.B   #CR,D0
        BEQ     DONE
        CMP.B   #LF,D0
        BEQ     DONE
        BSR     PUTCH
        BRA     ECHO

DONE    TRAP    #14             ; Halt Board? Trap to Monitor

**********************************************************************
* Output character in D0 to UART

PUTCH   BTST.B  #3,STATREG      ; Test TDRE bit to see if transmit buffer empty
        BEQ     PUTCH           ; Branch back until Transmit Data Register is empty
        MOVE.B  D0,XMIT         ; Send a character
        RTS                     ; Return

**********************************************************************
* Output string pointed to by A0, destroys D0 and A0

PUTS    MOVE.B  (A0)+,D0        ; Get next character from string
        BEQ     PUTS1           ; End-of-string NUL detected
        BSR     PUTCH           ; Output character
        BRA     PUTS            ; repeat
PUTS1   RTS                     ; Return

**********************************************************************
* Get character from UART in D0 (7-bit)

GETCH:  BTST.B  #0,STATREG      ; Test RDRF bit to see if receive buffer full
        BEQ.S   GETCH           ; Branch back until Receive Data Register is full
        MOVE.B  RECREG,D0       ; Character received and placed into D0
        AND.B   #$7F,D0         ; Mask off the parity bit so that it is just ASCII
        RTS                     ; Return

**********************************************************************
* Variables and Strings

MESSAGE DC.B    'Jello World! If Bill Cosby had invented the first C program',CR,LF,0

**********************************************************************

        END     START           ; last line of source, code entry point

Author:  mrpacijr [ Thu Apr 28, 2011 9:54 pm ]
Post subject: 

Thanks Clive! That is half of the battle for me! The terminal shows up everything I type with no problem....I now just have to get it to print to the LCD Screen when I hit ENTER (along with the restrictions)....If you need information on my board...I am using an Altera (Cyclone II FPGA Starter Board) with an Adapter board (DE1 68EC000) that has an LCD. My PC is connected with the board via a serial cable.

Author:  clive [ Thu Apr 28, 2011 11:55 pm ]
Post subject: 

Do you have any documentation for the board, I'm not able to find much on Google.

Do you have any more details on the UART, is it an FPGA implementation?

What LCD module are you using? How is it connected? Do you have addressing information, or a schematic?

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/