This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2541DK-MINI: CC2541

Part Number: CC2541DK-MINI
Other Parts Discussed in Thread: CC2540

I'm trying to form a shim with a timer and dma. With the help of dma, I want to write down the values in the compare register of the timer. I spend initialization, but for some reason the interrupt on DMA does not work. Help me please.

static uint8 a;
static uint8 LOW = 0x0C;
static uint8 HIGH = 0x1A;
static uint8 comp_mas[24];

DMA_DESC T3_DMA;

void RGB_init(void)
{
#if defined ( CC2540_MINIDK )
//RGB подсоединен к P1_4
//Будем использовать Timer3 Channel 1

PERCFG &= ~0x20; // Timer 3 Alternate location 1
P1DIR |= 0x10; // P1_4 = output
T3CTL &= ~0xE0; // Prescaler = 1

T3CTL &= ~0x10; // Stop timer 3 (if it was running)
T3CTL &= ~0x08; // Disable Timer 3 overflow interrupts
T3CTL |= 0x02; // Timer 3 mode = 1 - Modulo

T3CCTL0 &= ~0x40; // Disable channel 0 interrupts
T3CCTL0 |= 0x04; // Ch0 mode = compare


T3CCTL1 &= ~0x40; // Enable channel 1 interrupts
T3CCTL1 |= 0x04; // Ch1 mode = compare
T3CCTL1 |= 0x20; // Ch1 output compare mode = 100

#endif
}


//Процедура Отправки данных RGB
void RGB_start( uint32 mas )
{
uint32 a;

RGB_init();

a = 0x800000;

for (i=0; i < 24; i++)
{
if ((mas & a) == 0x00)
{
comp_mas[i] = LOW;
}
else
{
comp_mas[i] = HIGH;
}

a = a >> 1;
}

T3CTL |= 0x04; //Clear timer 3

T3CC0 = 0x28; //Установим значение до которого считать (частота 32МГц (0.03125 мкс, период 1.25 мкс)

T3CC1 = comp_mas[0];

timerStartDma (&T3_DMA, ((&comp_mas[1])));

P1SEL |= 0x10;
T3CTL |= 0x10; //Start Timer


while (1)
{

}

T3CTL &= ~0x10; // Stop timer 3
P1SEL &= ~0x10;
P1_4 = 0;

}

void timerStartDma (DMA_DESC *timerDmaDescr,

uint8 *timerBuf)
{
timerDmaDescr->SRCADDRH = (unsigned short) (timerBuf)>>8;
timerDmaDescr->SRCADDRL = (unsigned short) (timerBuf);
timerDmaDescr->DESTADDRH = 0x70;
timerDmaDescr->DESTADDRL = 0xCF;
timerDmaDescr->LENH = 0x00;
timerDmaDescr->LENL = 23;

timerDmaDescr->VLEN = HAL_DMA_VLEN_USE_LEN ;
timerDmaDescr->WORDSIZE = HAL_DMA_WORDSIZE_BYTE;
timerDmaDescr->TMODE = HAL_DMA_TMODE_SINGLE;
timerDmaDescr->TRIG = HAL_DMA_TRIG_T3_CH0;
timerDmaDescr->SRCINC = HAL_DMA_SRCINC_1;
timerDmaDescr->DESTINC = HAL_DMA_DSTINC_0;
timerDmaDescr->IRQMASK = HAL_DMA_IRQMASK_ENABLE;
timerDmaDescr->M8 = HAL_DMA_M8_USE_8_BITS;
timerDmaDescr->PRIORITY = HAL_DMA_PRI_HIGH;


DMA0CFGH = (unsigned char) ((unsigned short) timerDmaDescr>>8);
DMA0CFGL = (unsigned char) ((unsigned short) timerDmaDescr & 0xFF);

DMAARM = 0x01;
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");

IEN0 |= 0x80;
IEN1 |= 0x01;
IRCON &= ~0x01;

}

_PRAGMA (vector = DMA_VECTOR)
__interrupt void DMA_ISR(void)
{

IRCON &= ~0x01;

if (DMAIRQ & 0x02)
{
DMAIRQ &= ~0x02;
}

}

  • Hi Evgeniy,

    I have assigned one of our experts to look at this.

    Cheers,
    Fredrik
  • Hello Evgeniy,
    Is your DMA_DESC defined like this?

    // Place the bitfield members from the most significant bit to the least significant bit.
    #pragma bitfields=reversed
    typedef struct {
    unsigned char srcAddrH;
    unsigned char srcAddrL;
    unsigned char destAddrH;
    unsigned char destAddrL;
    unsigned char vlen : 3;
    unsigned char lenH : 5;
    unsigned char lenL : 8;
    unsigned char wordSize : 1;
    unsigned char tMode : 2;
    unsigned char trig : 5;
    unsigned char srcInc : 2;
    unsigned char destInc : 2;
    unsigned char irqMask : 1;
    unsigned char m8 : 1;
    unsigned char priority : 2;
    } DMA_DESC;
    #pragma bitfields=default