尊敬的TI工程师;
你好,我用的C5505-开发板ezdsp-usb,现在调试SPI遇到如下问题:
1、单独调试SPI,波形正常。
2、加上UART串口程序,SPI 正常工作,但是UART 没有数据输出。
3、去掉SPI,单独UART,UART正常工作。
不知道哪里配置错了,UART和SPI一起调试的时候不工作。
void spirom_init( ) { /* Enable SPI */ SYS_EXBUSSEL = (SYS_EXBUSSEL & 0x0fff) | 0x1000; SYS_PRCNTR = 0x04; SYS_PRCNTRLR = 0x0080;/* SPI Clock Control */SPI_SPICC2 = 0x0000; // SPI clock disabledSPI_SPICC1 = 0x00b0; // 12MHz input clock divided by 120SPI_SPIDC1 = 0x0000; // SPI0 low idle clock, active low CS, shift out on rising clock, no clock delaySPI_SPIDC2 = 0x0000;SPI_SPICC2 = 0x8000; // SPI clock enabled } void uart_txIsr() { if( i_timeeee < 7 ) {i_timeeee++;UART_write( hUart,&Rx_mcu[i_timeeee],i_timeeee,1000);//USBSTK5505_waitusec( 100 ); } UART_eventEnable(hUart,CSL_UART_XMITOR_REG_EMPTY_INTERRUPT); // } CSL_UartSetup mySetup = { /* Input clock freq in MHz */98304000, /* baud rate */9600, /* word length of 8 */CSL_UART_WORD8, /* To generate 1 stop bit */1, /* Disable the parity */CSL_UART_DISABLE_PARITY, /*disable fifo */CSL_UART_FIFO_DISABLE, /*enable trigger 14 fifo */ // CSL_UART_FIFO_DMA1_DISABLE_TRIG14, /* Loop Back enable */CSL_UART_NO_LOOPBACK, /**No auto flow control*/ CSL_UART_NO_AFE , /** No RTS */ CSL_UART_NO_RTS , }; Uint16 uart_IntcSample(void) {UART_init(&uartObj,CSL_UART_INST_0,UART_POLLED);hUart = (CSL_UartHandle)(&uartObj);/* Configure UART registers using setup structure */UART_setup(hUart,&mySetup);/* Loop counter and error flag */status = UART_init(&uartObj,CSL_UART_INST_0,UART_INTERRUPT);if(CSL_SOK != status){printf("UART_init failed error code %d\n",status);return status;}/** Handle created*/hUart = (CSL_UartHandle)(&uartObj);/* Configure UART registers using setup structure */status = UART_setup(hUart,&mySetup);if(CSL_SOK != status){printf("UART_setup failed error code %d\n",status);return status;} isrAddr.rbiAddr = uart_rxIsr; isrAddr.tbeiAddr = uart_txIsr; isrAddr.ctoi= uart_ctoIsr; isrAddr.lsiAddr =uart_lsiIsr; IRQ_clear(UART_EVENT); IRQ_setVecs((Uint32)(&VECSTART)); /* Configuring Interrupt */ IRQ_plug (UART_EVENT, &UART_intrDispatch); /* Enabling Interrupt */ IRQ_enable(UART_EVENT); IRQ_globalEnable(); UART_setCallback(hUart,&isrAddr); status = UART_eventEnable(hUart, CSL_UART_XMITOR_REG_EMPTY_INTERRUPT); status = UART_eventEnable(hUart, CSL_UART_RECVOR_REG_DATA_INTERRUPT); status = UART_eventEnable(hUart, CSL_UART_RECVOR_LINE_STATUS_INTERRUPT); return 0; } interrupt void UART_intrDispatch(void) { Uint16 eventId = 0; IRQ_disable(UART_EVENT); /* Get the event Id which caused interrupt */ eventId = UART_getEventId(hUart); if (((void (*)(void))(hUart->UART_isrDispatchTable[eventId]))) { ((void (*)(void))(hUart->UART_isrDispatchTable[eventId]))(); } IRQ_enable(UART_EVENT); return; }
xyz549040622:
是不是加上spi后串口中断的问题,你试试串口循环等待发送,不要用中断,波特率降低看看。
Shine:
回复 xyz549040622:
有没有跟过代码?看是不是不能进入uart发送中断子程序?
YUDONG WANG2:
回复 Shine:
刚才试了,不能进入发送中断。
YUDONG WANG2:
回复 Shine:
我在主程序循环发送,不用中断,也发不了数据。同样,把SPI关掉,UART就可以发送数据了
Shine:
回复 YUDONG WANG2:
查一下IFR寄存器的uart中断使能位有没有置1?
用一下中断嵌套避免丢中断。
xyz549040622:
回复 YUDONG WANG2:
主程序循环发送也出不去,那就不应该了,不用中断的话,死等待肯定是可以发出去的。