jayapal chandran

DEMO9SO8QG8 -- TESTING WITH SINGLE ADC channel

Discussion created by jayapal chandran on Dec 1, 2008
Latest reply on Feb 18, 2009 by jayapal chandran
our problem,
 
using demo9s08qg8 board ,control led1, led2  when ever read from adc value its compare  X  value accorading led1 on,led2 off
i write sample program
 
 
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC9S08QG8.h> /* include peripheral declarations */
 
 

#define LED1 PTBD_PTBD6
#define LED1_DDR PTBDD_PTBDD6
#define LED1_MASK PTBD_PTBD6_MASK
#define LED2 PTBD_PTBD7
#define LED2_DDR PTBDD_PTBDD7
#define LED2_MASK PTBD_PTBD7_MASK
#define ON 1
#define OFF 0

void ADC_Init(void)
  {

// set up adc
  ADCSC1=0x63; // all channels selected disables the ADC
    
 
  ADCSC2=0x00;   // select software trigger
    
  ADCCFG=0x90;      // bus clock
                   
 
 
  APCTL1=0x08;
   
           //APCTL1 = 0x00;  // Disable all pins as ADC     }inputs
  }
 
  
 
  void main(void)
  
{
 ADC_Init();   // Microcontroller initialization
   
   for (;:smileywink: {
         
        __RESET_WATCHDOG(); // Kicks the dog         
         
          while(ADCSC1_COCO==1);
         
            
        {
        
         if (ADCRL > 0x00) // ATD Output => 0xBF
         {
           PTBDD_PTBDD6=1;
         }
         else
         
          {
            PTBDD_PTBDD7=1;
         }
          
     }// End While
       
 }// Loop forever
   
}//end main(void)
 
interrupt 19 void  ADC_ISR (void)
{
 
  ADCRL=ADCSC1_ADCH;
 
  ADCSC1_AIEN=0;
}
 pls check this coding correct or not
 

Outcomes