Configuring adc of tms470r1b1m controller
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.............