We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I am currently trying to modify an existing code to display 12 bit data (C8051F206) instead of 8 bit data (C8051F226).
When I download the existing codes and run the program, my LCD is able to display some values. However, when I modify the program to display 12 bit data, the LCD just show 0.000V when I adjusted the ADC input. May I know what is different in the ADC configuration that I have to change ? What is wrong with my 12 bit code?
8-bit code:
//----------------------------------------------------------------------------- // Global CONSTANTS //----------------------------------------------------------------------------- unsigned int q,value,temp; unsigned char a,b,c,d; float bit_value,result; /*------------------ // ADC Conversion -------------------*/ void adcdata() { ADCINT = 0; ADBUSY = 1; ldelay(100); while(ADCINT==0); value = ADC0L; value = value*256; ldelay(900); ldelay(1000); ADCINT=0; ADBUSY=0; } /*------------------------------------------------------ // Bit Resolution: result = Voltage reference*(255/256) -------------------------------------------------------*/ void bit_resolution() { bit_value = 3.2/(256); result = value*bit_value; }
My 12 bit code (Left justified ADCOH:ADCOL):
//----------------------------------------------------------------------------- // Global CONSTANTS //----------------------------------------------------------------------------- unsigned int q,value,value1,temp,totvalue; unsigned char a,b,c,d,e; /*------------------ // ADC Conversion -------------------*/ void adcdata() { ADCINT = 0; value=0; ADBUSY = 1; ldelay(100); while(ADCINT==0); value = ADC0L; e= 0x0F & ADC0H; value1=e; totvalue= value + value1*256; ldelay(900); ldelay(1000); ADCINT=0; ADBUSY=0; } Appreciate if anyone could help. Thanks!!
Hi Dan,
Thanks for your reply. However, when I changed from "3" to "3.0", I still could not get the program working.
I am wondering if there is anything wrong with my syntax or is there anything needed to be changed to my current ADC configuration:
/*---------------- ADC Configuration -----------------*/ AMX0SL = 0xE0; // AMUX Channel Select Register; Analog input at P0.0 ADC0CF = 0x78; // ADC Configuration Register ADC0CN = 0x40; // ADC Control Register ADC0LTH = 0x00; // ADC Less-Than High Byte Register ADC0GTH = 0x00; // ADC Greater-Than High Byte Register