📄 inituart.asm
字号:
/* This program enables UART0 in transmit and receive mode. The UART0 transmit
signal is connected to DPI pin 9 */
#include <def21369.h>
.global _initUART;
.extern _xmitmsg;
.section/dm seg_dmda;
.var welcome_message[] = {12,'Hello!',
13,10,'This program echoes back whatever you type in...',13,10};
.global welcome_message;
.section/pm seg_pmco;
_initUART:
/* Sets the Baud rate for UART0 */
ustat1= UARTDLAB;
dm(UART0LCR) = ustat1; //enables access to Divisor register to set baud rate for UART0
r0=0x1c; dm(UART0DLL) = r0;
r0=0x2; dm(UART0DLH) = r0; //0x21c = 540 for divisor value and gives a baud rate of 19200 at 331.776Mhz core clock
/* Configures the UART LCR */
ustat1 = UARTWLS8| // word length 8
UARTPEN| // parity enable for odd parity
UARTSTB ; // two stop bits
dm(UART0LCR) = ustat1; // sets UART0 Line with one stop bit, odd parity and with baud rate of 19200
ustat1 = UARTEN;
dm(UART0TXCTL) = ustat1; // enable UART0 transmitter
ustat1 = UARTEN;
dm(UART0RXCTL) = ustat1; // enables UART0 in receive mode
r0 = welcome_message;
r1 = length(welcome_message);
call _xmitmsg; // function to transmit welcome message
_initUART.end:
rts;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -