I only posted this question after i tried everything I could. I am trying to use uartlite with microblaze and interrupt controller (nexysvideo board) to receive some data. I wrote a lot of variations but it doesnt seem to work. my simplest basic code was to turn on a led when a byte is received. building of the project is fine, no errors but nothing happens when runing in hardware. i also tried the provided example (uartlite_intrc_example) which ask for a physical loopback (my understanding is that i have to send back whatever data i receive in the terminal, but i m not sure, i m not a native english speaker) which also did not work. can anyone please point me on how to use the uartlite in this mode (not the provided examples unless i was misusing it). I do not even know if i am using the ip drivers and functions correctly. this an example of what i did:
while (!XUartLite_IsReceiveEmpty(XPAR_AXI_UARTLITE_0_BASEADDR)) {
flag = 1; } }
int main () {
initialize_system();
while (1) {
if (flag == 1) {
XGpio_DiscreteWrite(&gLED, LED_CHANNEL, LED);
}} return 1; }
(just a side notice: what does the TX led LDI13 in nexys video board refers to? it's on when i send data over uart. i thought it should be RX for receiving data?)
Question
nattib
Hi everyone,
I only posted this question after i tried everything I could. I am trying to use uartlite with microblaze and interrupt controller (nexysvideo board) to receive some data. I wrote a lot of variations but it doesnt seem to work. my simplest basic code was to turn on a led when a byte is received. building of the project is fine, no errors but nothing happens when runing in hardware. i also tried the provided example (uartlite_intrc_example) which ask for a physical loopback (my understanding is that i have to send back whatever data i receive in the terminal, but i m not sure, i m not a native english speaker) which also did not work. can anyone please point me on how to use the uartlite in this mode (not the provided examples unless i was misusing it). I do not even know if i am using the ip drivers and functions correctly. this an example of what i did:
#include <stdio.h>
#include "xparameters.h"
#include "xuartlite_l.h"
#include "xuartlite.h"
#include "xstatus.h"
#include "xintc.h"
#include "xgpio.h"
#include "xil_printf.h"
/************************GLOBAL VARIABLES******************************/
#define gLED_DEVICE_ID XPAR_GPIO_0_DEVICE_ID
#define LED_CHANNEL 1
#define LED 0x01
XIntc IntCntroller;
XUartLite UartLite;
XGpio gLED;
static volatile int flag= 0;
//****************************functions prototypes******************/
void uart_int_handler(void *baseaddr_p);
XStatus initialize_system ();
/************************************************************************/
XStatus initialize_system () {
XStatus status = XST_SUCCESS;
status = XUartLite_Initialize(&UartLite, XPAR_UARTLITE_0_DEVICE_ID);
if (status != XST_SUCCESS) {return XST_FAILURE; }
status = XUartLite_SelfTest(&UartLite);
if (status != XST_SUCCESS) { return XST_FAILURE; }
XUartLite_EnableInterrupt(&UartLite);
status = XIntc_Initialize(&IntCntroller, XPAR_INTC_0_DEVICE_ID);if (status != XST_SUCCESS) {return XST_FAILURE; }
status = XIntc_Connect(&IntCntroller,XPAR_INTC_0_UARTLITE_0_VEC_ID,(XInterruptHandler)&uart_int_handler, XPAR_UARTLITE_0_BASEADDR);
if (status != XST_SUCCESS) {return XST_FAILURE; }
XIntc_Enable(&IntCntroller, XPAR_INTC_0_UARTLITE_0_VEC_ID);
Xil_ExceptionInit();
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
(Xil_ExceptionHandler)XIntc_DeviceInterruptHandler,
(void*)XPAR_INTC_0_DEVICE_ID);
Xil_ExceptionEnable();
status = XIntc_Start(&IntCntroller, XIN_REAL_MODE);if (status != XST_SUCCESS) {return XST_FAILURE; }
status = XGpio_Initialize(&gLED, gLED_DEVICE_ID);
if (status != XST_SUCCESS) { return XST_FAILURE; }
XGpio_SetDataDirection(&gLED, LED_CHANNEL, ~LED);
return status; }
///////////////**************///////////////////
void uart_int_handler(void *baseaddr_p) {
while (!XUartLite_IsReceiveEmpty(XPAR_AXI_UARTLITE_0_BASEADDR)) {
flag = 1; } }
int main () {
initialize_system();
while (1) {
if (flag == 1) {
XGpio_DiscreteWrite(&gLED, LED_CHANNEL, LED);
}} return 1; }
(just a side notice: what does the TX led LDI13 in nexys video board refers to? it's on when i send data over uart. i thought it should be RX for receiving data?)
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.