Configuring adc of tms470r1b1m controller

im using #-Link-Snipped-# 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 
#include "iotms470r1b1m.h"
#include "tms470r1b1m_bit_definitions.h"
#include 

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.............

Replies

  • Harshad Italiya
    Harshad Italiya
    Have you tried a sample code given on the TI site?

    i had used ADC but it was on MSP series controller.
  • resmyanand
    resmyanand
    yes i tried the code...but its not working because the device is not selected
  • shreyasm89
    shreyasm89
    Your 2nd error is because ADC isn't activated(obviously!)Also are you sure that the 'for' loop condition shouldn't have a bracket ending?Have you eliminated all syntactical errors?Also you have rewritten the value in ADCR1 twice in successive instructions. How come?
  • resmyanand
    resmyanand
    shreyasm89
    Your 2nd error is because ADC isn't activated(obviously!)Also are you sure that the 'for' loop condition shouldn't have a bracket ending?Have you eliminated all syntactical errors?Also you have rewritten the value in ADCR1 twice in successive instructions. How come?


    it is for(;😉 unconditional for loop.there was no syntax error.
    i need ADCR1 to set -
    -COS(BIT15),CONTINUE ON SUSPEND ENABLE to continue channel conversion till completion when suspend mode is entered,
    -ADCEN(BIT5)to enable the ADC and
    -3 prescalar bits(bits 2,1,0).
    For this i had set ADCR1=8027 instead of the successive instructions.
    but the problem persists.....

You are reading an archived discussion.

Related Posts

Dear CEans, In a friendly discussion with fellow member Manish (a.k.a goyal420), we were talking about the importance of engineers to know more and more about strategies, especially business strategies....
I just love the look of CE using uBuntu font in uBuntu 10.10. I wonder we've anyone else using uBuntu 10.10 and the Firefox default font set to uBuntu?
hi, can anybody suggest me some good algorithms or paper for generation of nonce such that the nonce can be generated using time value i.e. at a particular time, by...
Hi everyone, I have finalized my project, that is a device to count the number of vehicles entering a building from but it need to be wireless. From the main...
Hello friend's, Anybody have idea how to create a bootable disk from our installed OS. Like suppose i have installed ubuntu 10.04 LTS on my pc and i waant to...