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.

CC2530 timer1 problem

Other Parts Discussed in Thread: CC2530

Hi all

    I want to generate IR signal.I have used timer3 to get the 38k carrier seccussfully,but I can't get modualted code(PWM) when I used timer1. 

I start the timer1 and update the T1CC0 and T1CC1 at the ISR of ch1 compare up.I want to stop timer use this code :T1CTL =0.

I have wrote the code like this,IR_data is the testing data of PWM wave,what is the problem?

unsigned short IR_data[4]={0x0200,0x0100,0x0050,0x0500};

void main(void)
{
    CLKCONCMD &= ~0x40;      //设置系统时钟源为32MHZ晶振
  while(CLKCONSTA & 0x40); //等待晶振稳定为32M
  CLKCONCMD &= ~0x07;      //设置系统主时钟频率为32MHZ  
  CLKCONCMD &= ~0x20;       //时钟速度32 MHz 定时器标记输出设置[5:3]8MHz
  CLKCONCMD |= 0x10;       //时钟速度32 MHz 定时器标记输出设置[5:3]8MHz
  CLKCONCMD &= ~0x08;       //时钟速度32 MHz 定时器标记输出设置[5:3]8MHz

  while(1)
    {
      if(P0_1 == 1)
      {
  MyDelay(100);
  if(P0_1 == 0)
  {
   
   
            PERCFG |= 0x40;        
      P2SEL &= ~0x10;    
      P2DIR |= 0x80;          

  

  
    
  IR_data_index = 0; 
   time_tmp1=IR_data[IR_data_index++];
       time_tmp2=IR_data[IR_data_index++];   
   
      T1CC1H = time_tmp1/256;         
    T1CC1L = time_tmp1%256;          
    T1CC0H = (time_tmp1+time_tmp2)/256;          
    T1CC0L = (time_tmp1+time_tmp2)%256;
   T1CTL = 0x02;   //module mode
      T1CCTL1 = 0x1c;    //set on compare , reset on 0,compare mode    
      
   

    T1CCTL1 |= 0x40;          // 模式选择 通道1比较模式 使能timer1通道1的中断
    T1IE   = 1;    //使能timer1的中断
       EA  =1;    //使能总中断

    
   
  }
  }
    }

}

#pragma vector=T1_VECTOR
__interrupt void T1_IRQ(void)

 unsigned short time_tmp1 = 0;
 unsigned short time_tmp2 = 0;
 if(T1STAT | 0x02)
 {
 
  if(IR_data_index <4)
  {
    time_tmp1=IR_data[IR_data_index++];
       time_tmp2=IR_data[IR_data_index++];

     
    T1CC1H = time_tmp1/256;         
    T1CC1L = time_tmp1%256;          
    T1CC0H = (time_tmp1+time_tmp2)/256;          
    T1CC0L = (time_tmp1+time_tmp2)%256;
   
  }
  else
  {
   T1CTL =0;// stop timer
    T1IE   = 0;
       EA  =0;
  }
  
  
 }


 if(T1STAT | 0x20)
 { 
 
 }

 

           

}