Hello, dear participants of community!
Sorry for my english. Now I am working with CC2530 IR generaion.
I am using Timer1 & Timer3 for PWM and DMA for updating T1CC1 and T1CC0.
Source code for this:
static void appConfigTimer3(){
IRCTL |= 1; // timer3 AND timer1 for IR generation
T3CCTL0 = 1<<2 | 6<<3; // Compare mode 2
T3CC0 = 221; //period of PWM ~1/38kHz on 1/4 freq. prescaler
T3CCTL1 = 4<<3 | 1<<2; // Compare mode 3
T3CC1 = 110; // 50%
T3CTL = 2<<5 | 2; // prescaler, clr , mode
T3CTL |= 1<<2;
}
static void generateIRCommand(uint16 commandSize, uint16 *decompressedPeriods, uint16 *decompressedOffPeriods) {
uint16 timer1period, timer1toggle;
uint8 dmaDesc0[16];
uint8 dmaDesc1[16];
// Setup DMA
dmaDesc0[0] = ((uint16)&decompressedOffPeriods[1]) >> 8;
dmaDesc0[1] = (uint16)&decompressedOffPeriods[1];
dmaDesc0[2] = (uint16)&X_T1CC1H;
dmaDesc0[3] = (uint16)&X_T1CC1L;
dmaDesc0[4] = 0x00;
dmaDesc0[5] = commandSize-1;
dmaDesc0[6] = 1 << 1 | 0 << 5 | 2; // Wordsize 16bit | Single transfer mode | Timer1 trigger // 0x82;
dmaDesc0[7] = 1 << 2 | 1 << 3; //Use 7 LSB for transfer count | IRQMASK
dmaDesc1[0] = ((uint16)&decompressedPeriods[1]) >> 8;
dmaDesc1[1] = (uint16)&decompressedPeriods[1];
dmaDesc1[2] = (uint16)&X_T1CC0H;
dmaDesc1[3] = (uint16)&X_T1CC0L;
dmaDesc1[4] = 0x00;
dmaDesc1[5] = commandSize-1;
dmaDesc1[6] = 1 << 1 | 0 << 5 | 2; // Wordsize 16bit | Single transfer mode | Timer1 trigger // 0x82;
dmaDesc1[7] = 1 << 2 | 1 << 3; //Use 7 LSB for transfer count | IRQMASK
DMA0CFGH = (uint16)dmaDesc0 >> 8;
DMA0CFGL = (uint16)dmaDesc0;
DMA1CFGH = (uint16)dmaDesc1 >> 8;
DMA1CFGL = (uint16)dmaDesc1;
// Timer1 setup
timer1period = decompressedPeriods[0];
timer1toggle = decompressedOffPeriods[0];
T1CCTL0 |= 1<<2 ;
T1CC0L = timer1period;
T1CC0H = timer1period >> 8;
T1CC1L = timer1toggle;
T1CC1H = timer1toggle >> 8;
//DMA_IntConnect(&DMA_interrupt);
T1CCTL1 |= 1 << 2 | 1 << 5;
// Arm DMA channels
DMAARM = 0x03;
// Start Timer
T1CTL = 1 << 1; // Div 1, modulo mode
}
Code in MAIN function:
appConfigTimer3();
MCU_IO_PERIPHERAL_PREP(1, 1);
PERCFG |= 1<<6; //timer 1 alt.2
IEN1 |= 0x02; //halTimer32kIntEnable();
uint16 decompressedPeriods[] = {5, 3};
uint16 decompressedOffPeriods[] = {1, 1};
generateIRCommand(2, decompressedPeriods, decompressedOffPeriods);
But oscillograph show me only 1 peak and 4 idle periods in cycle (as I understand - only decompressedPeriods[0] and decompressedOffPeriods[0] is in use) and writing by DMA is not working.
DMAARM at the first time shows me 0x03 (output of UART). After that DMAARM is 0.
DMAIRQ ia always = 3.
Help me, please :)