#1楼主:CC2510 DMA触发不了的问题
文章发表于:2009-07-03 11:37
用CC2510的DMA功能在RAM的空间中进行数据的传输,采用手动触发的模式,编译也没有问题,为什么就是触发不了呢??还是程序跑飞了呢?麻烦高手给解答下,分析下问题吧 谢谢了.
/***************************************************************************
*This example test how to set up a DMA transfer between two RAM locations*
***************************************************************************/
#include <iocc2510.h>
#include <string.h>
#include <hal.h>
#include <cul.h>
#define uint unsigned int
DMA_DESC dmaChannel;
char sourceString[14] = "This is a test"; //56 bytes
char destString[14];
INT8 i;
INT8 errors = 0;
void initUARTtest(void);
void Delay(uint n);
void main(void)
{
initUARTtest(); //初始化串口
// Enable interrupts globally
INT_GLOBAL_ENABLE(INT_ON);
//Clearing the destination
memset(destString,0,sizeof(destString));
// Setting up the DMA channel.
SET_WORD(dmaChannel.SRCADDRH, dmaChannel.SRCADDRL, &sourceString); // The start address of the data to be transmitted
SET_WORD(dmaChannel.DESTADDRH, dmaChannel.DESTADDRL, &destString); // The start address of the destination.
SET_WORD(dmaChannel.LENH, dmaChannel.LENL, 15); // Setting the number of bytes to transfer.
dmaChannel.VLEN = VLEN_USE_LEN; // Using the length field to determine how many bytes to transfer.
dmaChannel.PRIORITY = PRI_HIGH; // High priority.
dmaChannel.M8 = M8_USE_8_BITS; // Irrelevant since length is determined by the LENH and LENL.
dmaChannel.IRQMASK = IRQMASK_DISABLE; // The DMA shall not issue an IRQ upon completion.
dmaChannel.DESTINC = DESTINC_1; // The destination address is to be incremented by 1 after each transfer.
dmaChannel.SRCINC = SRCINC_1; // The source address inremented by 1 byte after each transfer.
dmaChannel.TRIG = DMATRIG_NONE; // The DMA channel will be started manually.
dmaChannel.TMODE = TMODE_BLOCK; // The number of bytes specified by LENH and LENL is transferred.
dmaChannel.WORDSIZE = WORDSIZE_BYTE; // One byte is transferred each time.
// Using DMA channel 1.
// Setting where the DMA channel is to read the desciptor and arming the DMA channel.
DMA_SET_ADDR_DESC1234(&dmaChannel);
DMA_ABORT_CHANNEL(1);
DMA_ARM_CHANNEL(1);
Delay(3000);
// Clearing all DMA complete flags and starting the transfer.
DMAIRQ = 0x00;
DMA_START_CHANNEL(1);//DMAREQ = 0x02;
// Waiting for the DMA to finish.
while(!(DMAIRQ & DMA_CHANNEL_1));
// Verifying that data is transferred correctly
for(i=0;i<sizeof(sourceString);i++)
{
if(sourceString[i] != destString[i])
errors++;
}
return;
}
/****************************************************************
*函数功能 :初始化串口1
*入口参数 :无
*返 回 值 :无
*说 明 :57600-8-n-1
****************************************************************/
void initUARTtest(void)
{
CLKCON &= ~0x40; //晶振--CLKCON.OSC(系统时钟选择)=0(高速晶振)
while(!(SLEEP & 0x40)); //等待晶振稳定--while(SLEEP.XOSC_STB=1)
CLKCON &= ~0x47; //TICHSPD128分频,CLKSPD不分频--CLKCON.OSC=0,CLKCON.CLKSPD=000(26MHZ)
SLEEP |= 0x04; //关闭不用的RC振荡器--SLEEP.OSC_PD=1
//PERCFG = 0x00; //位置1 P0口
//P0SEL = 0x3c; //P0用作串口
//U0CSR |= 0x80; //UART方式--U0CSR.MODE=1(UART mode)
//U0GCR |= 11; //baud_e = 11;
//U0BAUD |= 34; //波特率设为57600 --U0BAUD.DAUD_M=34,baud=[(256+34)*2^11]/2^28 *F
//UTX0IF = 1;
//U0CSR |= 0X40; //允许接收
//IEN0 |= 0x80; //开总中断
//IEN0 &= ~0x04; //关接收中断
}
/****************************************************************
*函数功能 :延时
*入口参数 :定性延时
*返 回 值 :无
*说 明 :
****************************************************************/
void Delay(uint n)
{
uint i;
for(i=0;i<n;i++);
for(i=0;i<n;i++);
for(i=0;i<n;i++);
for(i=0;i<n;i++);
for(i=0;i<n;i++);
}