我的Nexys2上嵌有一个Microblaze构建版,其中包含一个uartlite端口。我试图让它与液晶屏通信,但没有运气。这是我的代码,有人可以看到任何明显的错误吗?此外,LCD要求将整数发送给它以设置诸如背光,光标发布等内容。我该怎么做?对不起,我对C不太好。
/*
* Copyright (c) 2009 Xilinx, Inc. All rights reserved.
*
* Xilinx, Inc.
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
* COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
* ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
* STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
* IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
* FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
* XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
* THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
* ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
* FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE.
*
*/
/*
* helloworld.c: simple test application
*/
#include <stdio.h>
#include "platform.h"
#include "xparameters.h"
#include "mb_interface.h"
#define XPS_UART_0_RX_FIFO_VALID_DATA 0x01
#define XPS_UART_STATUS (*(volatile int*) (XPAR_UARTLITE_0_BASEADDR+8))
#define XPS_UART_RX_FIFO (*(volatile int*) (XPAR_UARTLITE_0_BASEADDR))
#define XPS_UART_TX_FIFO (*(volatile int*) (XPAR_UARTLITE_0_BASEADDR+4))
#define XPS_UART_0_TX_FIFO_FULL 0x08
char getcharacter(void);
void pucharacter(char character);
void putstring(char *stringptr);
void delayms(int ms);
int main()
{
char character;
putstring("Hello\n\r");
while(1){
//character = getcharacter();
putstring("Hello World");
}
return 0;
}
char getcharacter(){
unsigned int status;
char character;
while((XPS_UART_0_RX_FIFO_VALID_DATA & XPS_UART_STATUS) ==0){
status = XPS_UART_STATUS;
}
character = XPS_UART_RX_FIFO;
return character;
}
void putcharacter(char character){
unsigned int status;
while(XPS_UART_0_TX_FIFO_FULL & XPS_UART_STATUS){
status = XPS_UART_STATUS;
}
XPS_UART_TX_FIFO = character;
}
void putstring(char*stringptr){
while(*stringptr != 0x00){
putcharacter(*stringptr);
stringptr++;
}
}
void delayms(int ms){
int count;
for(count = 0; count <ms*256; count++){}
}