Hi, everyone: Does anybody has used ST3434E before? The easiset ADC gets me confused. Following is my code:
#include <ST/upsd3400.h> #include "DATATYPES.H" #include "ADC.h" sfr16 ADAT = 0x95; sfr16 P1SFS = 0x8e; #define ADC_ENABLE 0x20 #define ADC_START 0x02 #define ADC_BUSY 0x01 #define ADC_WORK (ADC_ENABLE | ADC_START) VOID ADC_Init(VOID) { P1SFS |= 0x0101; // ADC channel 0 //P1SFS0 = 0x01; //P1SFS1 = 0x01; ACON = ADC_ENABLE;// ADC enable, interrupt disable, channel 0 } WORD ADC_Read(VOID) { ACON = ADC_START; while (!(ACON & ADC_BUSY)); // wait until ADC is not busy //ACON &= ~ADC_ENABLE; return (ADAT); }
The bit 0 of ACON is status flag, when it is set to 1, the AD conversion completed. But it is never set!
Keil 8, JTAG debugger
Glad to hear it. Then I'm done for the night.
It's so kind of you. Wish you have a good night.