Hello,
I want to make a conversion using the 7th channel but it will not work, please tell me what is wrong. It works fine using ch 0 :
ATDCTL2 = 0x80;
ATDCTL3 = 0x08;
ATDCTL4_SRES8=1;
ATDCTL3_S4C=0;
ATDCTL3_S2C=0;
ATDCTL3_S1C=1;
ATDCTL4_SMP1=0;
ATDCTL4_SMP0=0;
ATDCTL4_PRS0=0;/
ATDCTL4_PRS1=0;
ATDCTL4_PRS2=0;
ATDCTL4_PRS3=0;
ATDCTL4_PRS4=0;
ATDCTL5_SCAN = 1;
ATDCTL5_MULT=0;
ATDCTL5_CA=1;
ATDCTL5_CB=1;
ATDCTL5_CC=1;
x=ATDDR7H;
PORTB=x; //the LED's from PORTB should start blinking
x- never changes it's value (it is always 0). The same in the the debugger: x=0......
If I select channel 0, it works fine, the LED's are blinking..x changes it's value.
I would use ch0, but it is ocupied by a potentiometer .
Thank you
Added p/n to subject.
//===============================================================================// ADC// Dragons have a pot on channel 7. We use// this for controlling the brightness of the 7-seg LEDs.//=============================================================================== // ADC Defines.#define MULTI_MODE 0x10#define SINGLE_MODE 0#define SCAN_MODE 0x20#define NO_SCAN_MODE 0#define POT_CHANNEL_NUM 0x7 // reading input from AN07#define SCF 0x80 //Sequence Complete Flag in ATD0STAT0byte ADTValue;//===============================================================================// Trigger Read, wait, then read a channel and return 8-bit value..//===============================================================================byte ReadADC(byte channel) { byte status; // This resets the conversion done flag and starts a new conversion. ATD0CTL5 = SINGLE_MODE+NO_SCAN_MODE+channel; for (;;) { status = ATD0STAT0; if( status & SCF ) break; } status = ATD0DR7H; // Just the hi byte. Ignore LSB's ADTValue = status; return status; } // Init code - put in main. // ATD block set up. ATD0CTL2 = 0x80; // Enable power up mode for ADC Block ATD0CTL3 = 0x40; // Set 8 bit conversions. // Set the enable digital input for the switches SW1-SW4 ATD0DIEN = 0xff;