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.

CONFIGURING ADC OF TMS470R1B1M

Other Parts Discussed in Thread: TMS470R1B1M

im using tms470r1b1m controller for my project.i need an ADC for processing the analog input.

in iar workbench,i had configured the registers but the code is not working.

code is given below.plz give me a solution..........

#include <intrinsics.h>
#include "iotms470r1b1m.h"
#include "tms470r1b1m_bit_definitions.h"
#include <stdio.h>

void main(void)
{
  int result;
  PCR = CLKDIV_3;                         // ICLK = SYSCLK / 3
  GCR = ZPLL_CLK_DIV_PRE_1;               // SYSCLK = 8 x fOSC
  PCR = PENABLE;                         // Enable peripherals


  PLR = (PLOC3&0);                      //peripheral selects, The peripheral is internal
  PPROT = (PPROT3&0);             // peripheral selects,The peripheral is accessible in all modes
  CLKCNTL = 0x00000020;
 

  ADCR1 = PS_8;                          // ADCLK prescaler = 8
  ADCR1 = COS;
  ADCR2 |= G1_MODE;                       // Continuous Conversion
  ADSR =0x0000;                    // Clears flag
  ADEISR=0x0000;    // event disabled
  ADISR1 = 0x0020;   // Convert group 1 = channel 5
  ADISR2 = 0x0000;  //grp2 disabled
  ADCALR = 0x000;    //no Calibration
  ADSAMPEV = SEN;                        // ADCSAMP1 controls SW
  ADSAMP1 = 62;                           // SW = 62+2
  ADCR1 = ADC_EN;                        // Enable ADC
 
 
  for (;;)
  {
   
   while (!GP1_END);             // Wait for conversion to complete
   {
   }
    result = ADDR5;
    printf("RESULT is %d",result);
    ADSR =0x0000; 
 
  }
}

when this code is executed in iar workbench, the ADC is not activated nor does it sets GP1_END bit to indicate the completion signal.hence the code never exits from the while loop.here input is given to channel 5.i couldn't identify the problem..

plz give me a solution.............

  • Nikitha,

     

    Please be aware that the TMS470R1x series (tms470r1b1m) is not recommended for new designs.  Please see the full 'NRDN' notice here.

    Soon TI will be launching the new TMS470M series of microcontrollers.  This series will feature greater ARM CPU performance and a similar peripherial set to the TMS470R1 Series of microcontrollers.  Please come back soon for more information about the TMS470M Series of microcontrollers.  The product preview for the first two microcontrollers in the TMS470M series is available here: TMS470MF0660x - SPNS157. The TMS470M Series Technical Reference Manual is available here: TMS470M TRM.

    Best Regards,

     

    Jean-Marc Mifsud

  • .

    thank u

    i know that tms470r1b1m is not recommended for new designs. my purpose is for an academic project n only tms470r1b1m development board is available in lab.

    so currently i have no option of changing the board.so please give me a solution for the problem mentioned,for configuring the ADC.

    regards

    resmy

  • Resmy,

    The TMS470r1b1m is not a product I support directly. Anyway, I will try to help and found what is going wrong.

    Will it be possible to send me your project so I can debug it? This will be much easier for me.

    My email is jm-mifsud@ti.com

    Best Regards,

    Jean-Marc Mifsud

  • thank you....

    my project is for implementing a defibrillator analyser for biomedical applications.

    for this i have to  find the energy output  from defibrillator.

    Attenuated  Analog signal is given to ADC of the controller. digital output should be saved for processing.

    I have to take about 1500 samples for a single analog signal. 

    In further part i also need a timer to periodically interrupt the ADC.

    i couldnt proceed due to the problem in ADC.Code given is for taking a single sample output from ADC.

    regards,

    Resmy

     

  • Resmy,

    Sorry for the misunderstanding.

    To debug your ADC problem I need your full code project. Can you zip it and send it to me?

     

    Regards,

     

    Jean-Marc

  • Please try to enable ADC (  ADCR1 = ADC_EN;                        // Enable ADC) just after you prescale the ADC clock (ADCR1 = PS_8;                          // ADCLK prescaler = 8) and before all other ADC settings.  As:

      ADCR1 = PS_8;                          // ADCLK prescaler = 8

     ADCR1 = ADC_EN;                        // Enable ADC (This should be placed at the beginning after you prescale the clock)
     ADCALR = 0x000;    //no Calibration

      ADCR1 = COS;
      ADCR2 |= G1_MODE;                       // Continuous Conversion
      ADSR =0x0000;                    // Clears flag
      ADEISR=0x0000;    // event disabled
      ADISR2 = 0x0000;  //grp2 disabled
      ADSAMPEV = SEN;                        // ADCSAMP1 controls SW
      ADSAMP1 = 62;                           // SW = 62+2
     

    ADISR1 = 0x0020;   // Convert group 1 = channel 5 (This is the software trigger, right? should be placed after you finish configuring the ADC)
     

    ......

    The reason is: the ADC can only detects the trigger signal (software or hardware) after ADC_EN. This is recommended in the 470M and 570 devices. I am not familar with R1x devices. But, as a legecy device, it should be similar.

    Regards,

    Haixiao

     

  • SORRY..im on the development stage.not yet developed the code fully....

  • thank you..i tried as per your suggesion.but the same problem persists. should i change the operating mode from user mode to  any priviledged  mode for a peripheral to become operational? if  so how can it be done

    regards

    resmy

  • Resmy,

    I am going to post some code that works on R1x in continous mode.

    ..........

    ADC_SETUP_R1X(1); // the source code of this function is shown at the end

    // Disable self-test mode
      r1x_adc->ADCR1_UN.ADCR1_UL &= 0xfdff;
     
      // Disable calibratio mode
      r1x_adc->ADCR1_UN.ADCR1_UL &= 0xdfff;
     
      // Start channel GP1[X] conversion
      r1x_adc->ADISR1=SETUP->CHANNEL; //0x01;
     
      while(1) {
       
        // Checks GP1 CONV END bit
        while(r1x_adc->ADSR_UN.ADSR_ST.GP1_END_B1 != 1)
          {}
       
        //forcing for channel 0, this must be changed
        data = r1x_adc->ADDR_UN[0].ADDR_ST.DATA_B10; //[0].ADDR_UW;
        data &= 0x3FF; 
      }
    .....................

     

    source code for ADC_SETUP_R1X()

    void ADC_SETUP_R1X(int G1MODE) //G1MODE =1-> continous mode, =0; single conversion mode

    {
     
      //select registers to zero
      r1x_adc->ADEISR &= 0x0000;
      r1x_adc->ADISR1 &= 0x0000;
      r1x_adc->ADISR2 &= 0x0000;
      //calibration register to zero

      r1x_adc->ADCALR_UN.ADCALR_ST.CALR_B10 &= 0x000;
     
      //r1x_adc->ADCR1_UN.ADCR1_ST.PWR_DN_B1 = 0;
      r1x_adc->ADCR1_UN.ADCR1_UL &= 0xFEFF;

      //r1x_adc->ADCR1_UN.ADCR1_ST.ADC_EN_B1 = 1;
      r1x_adc->ADCR1_UN.ADCR1_UL |= 0x0020;
     
      r1x_adc->ADCR1_UN.ADCR1_UL |= (SETUP->ADC_SAMPLES << 3); //sample time

      r1x_adc->ADCR1_UN.ADCR1_UL |= SETUP->ADC_PRESCALER; //clock prescale

      if (G1MODE==1) {
        r1x_adc->ADCR2_UN.ADCR2_UL &= 0xFFDF;
      } else {
        r1x_adc->ADCR2_UN.ADCR2_UL |= 0x20;
      }
      return;
    }

    Hopefully, it helps.

    Regards,

    Haixiao

  • sorry..it doesnt work....nw im trying to simulate the entire system using proteus simulation tool