matrx2010 发表于 2011-10-12 22:01:32

microblaze 串口调试

初学EDK参考网上的例程写了一段程序
#include "xparameters.h"
#include "xgpio.h"
#include "xuartlite.h"
#include "xuartlite_l.h"
#include "xintc.h"
#include "xintc_l.h"
#include "xutil.h"

void uart_int_handler(void)
{
   XGpio gpio;
   unsigned char c;
/*till uart FIFOs are empty */
while(!XUartLite_mIsReceiveEmpty(XPAR_RS232_BASEADDR))
{
    c =XUartLite_RecvByte(XPAR_RS232_BASEADDR);
    XUartLite_SendByte(XPAR_RS232_BASEADDR, c);
    switch(c)
    {      
    case 0x31: XGpio_DiscreteWrite(&gpio, 1, ~0x01); break;
    case 0x32: XGpio_DiscreteWrite(&gpio, 1, ~0x02); break;
    case 0x33: XGpio_DiscreteWrite(&gpio, 1, ~0x04); break;
    case 0x34: XGpio_DiscreteWrite(&gpio, 1, ~0x08); break;
    case 0x35: XGpio_DiscreteWrite(&gpio, 1, ~0x10); break;
    case 0x36: XGpio_DiscreteWrite(&gpio, 1, ~0x20); break;
    case 0x37: XGpio_DiscreteWrite(&gpio, 1, ~0x40); break;
    case 0x38: XGpio_DiscreteWrite(&gpio, 1, ~0x80); break;
    default : break;
    }      
}
}

int main()
{

XUartLite RS232_Uart;
XGpio gpio;
xil_printf("--start the program test---\r\n");
XUartLite_Initialize(&RS232_Uart, XPAR_RS232_DEVICE_ID);
//initialize LED GPIO
XGpio_Initialize(&gpio, XPAR_LEDS_DEVICE_ID);
XGpio_SetDataDirection(&gpio,1,0x00);
//must enable mb_enable bit
microblaze_enable_interrupts();
XUartLite_EnableInterrupt(&RS232_Uart);

//register the isr
XIntc_RegisterHandler(XPAR_INTC_0_BASEADDR,
XPAR_XPS_INTC_0_RS232_INTERRUPT_INTR,
(XInterruptHandler)uart_int_handler,
(void *)0);

//must enable XIntc_mMasterEnable
XIntc_mMasterEnable(XPAR_INTC_0_BASEADDR);
//must enable specific interrupt(s) in the interrupt controller.
XIntc_mEnableIntr(XPAR_INTC_0_BASEADDR,XPAR_RS232_INTERRUPT_MASK);

while (1);
return 0;         
}

编译后报出这样的错误
/cygdrive/c/Users/matrx/AppData/Local/Temp/cc4G89ca.o: In function `main':
/cygdrive/f/FPGA/rs_test2/rs_led.c:50: undefined reference to `XIntc_mMasterEnable'
/cygdrive/f/FPGA/rs_test2/rs_led.c:50: undefined reference to `XIntc_mEnableIntr'
/cygdrive/f/FPGA/rs_test2/rs_led.c:58: undefined reference to `XUartLite_mIsReceiveEmpty'
/cygdrive/c/Users/matrx/AppData/Local/Temp/cc4G89ca.o: In function `uart_int_handler':
/cygdrive/f/FPGA/rs_test2/rs_led.c:20: undefined reference to `XUartLite_mIsReceiveEmpty'
网上说是没有链接到库,是指没有generate libraries and BSPs吗?但是编译前我有生成库的,请高人指点

matrx2010 发表于 2011-10-13 09:18:13

回复【楼主位】matrx2010
-----------------------------------------------------------------------

那位高手做过这方面的工程,指点一下,小弟不胜感激

matrx2010 发表于 2011-10-13 10:09:18

microblaze里使用中断外设的话,一定要用中断控制器吗(只有一个中断)?

zkf0100007 发表于 2011-10-16 14:46:57

必须要的

matrx2010 发表于 2011-10-17 08:46:18

回复【3楼】zkf0100007
-----------------------------------------------------------------------

那前辈知道我上面的程序那里出错的了吗?

zkf0100007 发表于 2011-10-18 00:43:55

你都到了编译这一步了,generate libraries and BSPs会自己做的,查一查吧,不会是你硬件没添加这个IP,编程时又引用,那肯定就不行了

wang110 发表于 2011-10-18 22:07:33

不知楼主使用的EDK是那个版本,高版本的EDK已将XIntc_mMasterEnable等等的中间的m取消,变成XIntc_MasterEnable

matrx2010 发表于 2011-10-20 10:28:20

回复【6楼】wang110
-----------------------------------------------------------------------

我用的是EDK12.2,果然是这个问题,6楼太强大了!

wangshaosh 发表于 2012-2-2 16:19:08

看信息是没找到XIntc_mMasterEnable' 这些函数

应该是有些头文件没有包含吧
页: [1]
查看完整版本: microblaze 串口调试