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.

changing Timer1 inplace of Timer0 is not working with ADC

Other Parts Discussed in Thread: CC430F5137

Hello,

I was using timer0 with SMCLK and was working well with the ADC  sampling when checked with a breapoint placed at result=ADC12MEM0; but when I tried to use Timer1 inplace of Timer0 it is not working and the code is shown below with timer1

void main( void )
{
	WDTCTL = WDTPW | WDTHOLD;
  REFCTL0 = REFON;//RefMaster;Internal REF_ON
  REFCTL0&=~REFMSTR;
  ADC12CTL0 = ADC12SHT0_4 + ADC12REFON + ADC12REF2_5V+ADC12ON;
  ADC12CTL1 =  ADC12SSEL_3+ ADC12SHS_1 + ADC12SHP ;
  ADC12CTL2 =  ADC12PDIV + ADC12RES_2;
  ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_3;
  P2SEL = BIT3;
  ADC12IE = ADC12IE0;
  ADC12CTL0 |= ADC12ENC;

  TA1CCR0 = Smclk/(100) - 1;
  TA1CCR1 = TA0CCR0 - 20;
  TA1CCTL1 = OUTMOD_3;
  TA1CTL = TASSEL_2 + MC_1;
  {
	  ADC12CTL0 |= ADC12SC;
    __bis_SR_register(CPUOFF + GIE);
  }
}

#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR(void)
{
	result=ADC12MEM0;//placed a breakpoint here
	__bic_SR_register_on_exit(CPUOFF);
}

Original working code is having Timer0 in place of Timer1 in these lines in the above shown code

 TA0CCR0 = Smclk/(100) - 1;
  TA0CCR1 = TA0CCR0 - 20;
  TA0CCTL1 = OUTMOD_3;
  TA0CTL = TASSEL_2 + MC_1;

can someone help out in finding tthe problem of why the timer1 is not working if it was working timer0.

Thnkas.

  • Hi,

    You did not mention what device you are using, but you need to also change the trigger source - ADC12SHS_x bits - to use your new timer - right now the ADC is still set to trigger off of the TA0 and this is why nothing is happening. ADC12SHS_1 in your code above must be for TA0.1 trigger on your part - you will need to check your device-specific datasheet to see what ADC12SHS_x setting you need for the ADC to trigger off of a different timer. 

    Regards,

    Katie

  • Sorry, I forgot to mention . I am using the cc430f5137 board with CCS.

    In the cc430f5137.h file it is mentioned like this 

    #define ADC12SHS_0 (0*0x400u) /* ADC12 Sample/Hold Source: 0 */
    #define ADC12SHS_1 (1*0x400u) /* ADC12 Sample/Hold Source: 1 */
    #define ADC12SHS_2 (2*0x400u) /* ADC12 Sample/Hold Source: 2 */
    #define ADC12SHS_3 (3*0x400u) /* ADC12 Sample/Hold Source: 3 */

    In the CC430 user's guide it is mentioned like this

    The source for SHI is selected with the SHSx bits and includes the following:
    • ADC12SC bit
    • Up to three timer outputs (see the device-specific data sheet for available timer sources)

    The CC430f5137 specific datasheet of page26 (here 1385.cc430f5137.pdf) says ADC12SHSx = {1}

    I was confused with this representation. so used both the ADC12SHS_2 and  ADC12SHS_3 for timer1 in place of  ADC12SHS_1 for timer0 but they didn't worked.

    But the ADC12SHS_0 is working for Timer1.

    But where it is mentioned about the particular clock selection .

    thanks.

  • Also there are only two timers:Timer1 and Timer0 for Timer_A type but why there are 4 soruce selects

    ADC12SHS_0,ADC12SHS_1,ADC12SHS_2,ADC12SHS_3.

    can someone explain where to find more information on this source selects.

  • Govardhan Reddy Patancheru said:

    The CC430f5137 specific datasheet of page26 (here 1385.cc430f5137.pdf) says ADC12SHSx = {1}

    I was confused with this representation. so used both the ADC12SHS_2 and  ADC12SHS_3 for timer1 in place of  ADC12SHS_1 for timer0 but they didn't worked.

    The datasheet is typically the place you should find this information because it varies from device to device which timers will be associated with which ADC12SHS_x setting. I too see only the 1 setting for Timer A0 CCR1 listed in the datasheet - this may be the only option on this particular device. I'm double checking internally to make sure this is really the case, as some of our other 5xx/6xx parts have more than one timer trigger option for the ADC. I'll post back as soon as I can confirm one way or the other.

    Regards,

    Katie

  • If you look on Page 27 of the datasheet in the Timer1 section (table), there is no output signal from the Timer routed to the ADC, so you cannot use Timer1 to trigger the ADC on this device. You will need to use Timer0.

    Govardhan Reddy Patancheru said:

    Also there are only two timers:Timer1 and Timer0 for Timer_A type but why there are 4 soruce selects

    ADC12SHS_0,ADC12SHS_1,ADC12SHS_2,ADC12SHS_3.

    This is because the same ADC12 module IP block is used from device, and TI's goal is for devices across the family to have the same register interface. The ADC12 is designed to have up to 4 trigger sources, but not every implementation has 4 trigger sources. The ones that aren't connected are tied off (to ground usually) when the IP is put in the die mask during design stage of a device.

  • Is this so that Tiemr1 can't be used for ADC trigger?

    But the thing is that the radio module code I am using is working with Timer0 in which it is stopping the Up_mode after a while (after some process).

    If I am using the same timer Timer0 for both radio and ADC sampling the ADC sampling is not working as the radio module code is making the stoppping the Up_mode and when it enters into the ADC sampling code it is not workign as the Up_mode was stopped.

    Is there is way to solve this issue.

    thanks.

  • Govardhan Reddy Patancheru said:
    Is there is way to solve this issue.

    Can you modify the radio module code to use Timer1 and you use Timer0 for the ADC?

**Attention** This is a public forum