I am trying to simulate the ADC of the C5051F120 on keil and i just cant seem to make it work. i dont know what i am missing. I have set my vref1 and vref0 voltage to 3V and and am not toucing the ADCOCF and ADC0CN regs and my AIN1 voltage i set between 1-3V and tried using it in AD0BUSY mode and timer2 overflow mode.I also execute a delay.please help and it would be great if someone could give me the code.
// I have tried all kinds of things in vain and am using the UV2 evaluation version #include<c8051f120.h> #include<intrins.h> /*void wait(unsigned int i) { unsigned int j; for(j==0;j<i;j++) _nop_(); }*/ void main() { char x=0; WDTCN=0xDE; WDTCN=0xAD; ADC0CN=0x9C; ADC0H=0x01; ADC0L=0x01; //EA=1; //EIE2=0x02; //EIP2=0x02; //ET2=1; //TR2=1; while(1) { //AD0EN=1; //AD0BUSY=1; //wait(10005); //AD0BUSY=0; //AD0INT=0; //EA=1; //EIE2=0x02; x=x++; // i just want the microcontoller to be busy } }