標(biāo)題: 【已經(jīng)解決,謝謝】CC2530 uart0 DMA通道1數(shù)據(jù)傳輸問題,200元酬謝 [打印本頁]
作者: sihhepl 時(shí)間: 2017-6-13 10:29
標(biāo)題: 【已經(jīng)解決,謝謝】CC2530 uart0 DMA通道1數(shù)據(jù)傳輸問題,200元酬謝
本帖最后由 sihhepl 于 2017-6-19 22:17 編輯
200元酬謝,請(qǐng)各位大俠幫我調(diào)下程序,謝謝啦!我的QQ:79422195,請(qǐng)標(biāo)注“51黑DMA”
我使用cc2530的DMA channel 1將接收到的串口(uart0)數(shù)據(jù)存儲(chǔ)在uartRxBuf內(nèi),程序如下。在中斷函數(shù)中,根據(jù)DMAIRQ的DMAIF1位是否置1來判斷是否傳輸完成DATA_COUNT字節(jié)的數(shù)據(jù)。如果DATA_COUNT為1,則程序沒有問題,接收數(shù)據(jù)正常,如果DATA_COUNT大于1,則程序不能產(chǎn)生中斷。請(qǐng)各位大俠幫我看下程序,謝謝啦!
#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;
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/) |
Powered by Discuz! X3.1 |