CC2530 uart0 DMA通道1数据传输问题, 悬赏200元
[复制链接]
本帖最后由 sihhepl 于 2017-6-15 09:32 编辑
悬赏200元,请各位大侠帮我调下程序,谢谢啦!我的QQ:79422195,请标注“电子工程世界DMA”
我使用cc2530的DMA channel 1将接收到的串口(uart0)数据存储在uartRxBuf内,程序如下。在中断函数中,根据DMAIRQ的DMAIF1位是否置1来判断是否传输完成DATA_COUNT字节的数据。如果DATA_COUNT为1,则程序没有问题,接收数据正常,如果DATA_COUNT大于1,则程序不能产生中断。
#define HAL_URX0_DMA_CH 1 #define DATA_COUNT 10 uint8 uartRxBuf[15] = {0}; void HalDma_uart( void ) { halDMADesc_t *ch; ch = HAL_DMA_GET_DESC1234(HAL_URX0_DMA_CH) ch->srcAddrH = HI_UINT16(&X_U0DBUF); ch->srcAddrL = LO_UINT16(&X_U0DBUF); ch->dstAddrH = HI_UINT16(uartRxBuf); ch->dstAddrL = LO_UINT16(uartRxBuf); ch->vLen = 0x00;// Use fixed length DMA transfercount ch->lenH = HI_UINT16(DATA_COUNT); ch->lenL = LO_UINT16(DATA_COUNT); ch->wordSize =HAL_DMA_WORDSIZE_BYTE;// Perform 1-byte transfers ch->tMode =HAL_DMA_TMODE_SINGLE;// Single byte transfer per DMA trigger ch->trig = HAL_DMA_TRIG_URX0;// DMA trigger =USARTx RX complete ch->srcInc = HAL_DMA_SRCINC_0;// Do not incrementsource pointer, points to USART U0BUF register. ch->destInc = HAL_DMA_DSTINC_1;// Increment destinationpointer by 1 byte address after each transfer. ch->irqMask = HAL_DMA_IRQMASK_DISABLE;// Enable DMAinterrupt to the CPU ch->m8 = HAL_DMA_M8_USE_8_BITS;// Use all 8bits for transfer count ch->priority =HAL_DMA_PRI_HIGH;// DMA memory access has low priority /* The DMAconfiguration data structure may reside at any location in * unified memoryspace, and the address location is passed to the DMA * through DMA1CFGH:DMA1CFGL. */ HAL_DMA_CLEAR_IRQ(HAL_URX0_DMA_CH);
HAL_DMA_SET_ADDR_DESC1234( ch );
HAL_DMA_ARM_CH(HAL_URX0_DMA_CH); // Arm DMAchannel 1 //apply 45 NOP's forloading DMA configuration asm("NOP");asm("NOP");//45clk periods //Enable the DMAinterrupt (IEN1.DMAIE = IEN0.EA = 1), //and clear potentialpending DMA interrupt requests (IRCON.DMAIF = 0) IEN0 |= 0x80; IEN1 |= 0x01; IRCON &= ~0x02; // Enable UARTx RX U0CSR |= 0x40; }
|