??? 08/13/07 18:02 Read: times |
#143205 - sorry for confusing you but Responding to: ???'s previous message |
believe me, your question also confused me. Then I took the time to read your parallel post and it became clear to me that you use an 8 BIT ADC.
You should describe your problem in more detail otherwise no one can help you !! Also by reading the parallel thread I figured out: >> He would have been able to measure upto 3V if he had set >> ADC0CF to 0x7F which sets the PGA gain to 0.5. It took me >> quite some time to realise this too. Next time, please take your time. About your code, if this is really your original code it can not run. In main you need an endless loop. Keep in mind, you are not writing some code that will return to an OS !! About building an average please have a look. I don't use your Chip and I did not test it so see it as a pseudocode. Make sure that the adc is used as described in the datasheet. void adcdata () { uint16_t adc_sum = 0; uint8_t adc_count = 0; for (adc_count = 0; adc_count < 16; adc_count ++) { ADCINT = 0; ADBUSY = 1; while (!ADCINT); // conversion complete ? adc_sum += ADC0H; // build an average }adc_sum >>=4; // /16 => 8 BIT result } Now you have an average over 16 samples. Of course, adc_sum should be global or returned by the function. About your main code, I guess it should look like this ? void main () { config(); ADCEN = 1; // enable ADC while (1) { // endless loop delay (500000); adcdata (); delay (500000); } } So one more time, did you post your real code ? Why do you use a signed char ? And again, please send a schematic diagram to get an idea of what are you doing. |
Topic | Author | Date |
ADC Problem | 01/01/70 00:00 | |
Circuit ? | 01/01/70 00:00 | |
Clarify? | 01/01/70 00:00 | |
Crosspost | 01/01/70 00:00 | |
Clarification | 01/01/70 00:00 | |
Still no circuit | 01/01/70 00:00 | |
Power supply | 01/01/70 00:00 | |
What about the adc lowbyte ? | 01/01/70 00:00 | |
Power Supply | 01/01/70 00:00 | |
Power supply | 01/01/70 00:00 | |
Power Supply | 01/01/70 00:00 | |
ADC lowbyte | 01/01/70 00:00 | |
sorry for confusing you but | 01/01/70 00:00 | |
Thanks for the time | 01/01/70 00:00 | |
mmmhhh one more time | 01/01/70 00:00 | |
LCD code | 01/01/70 00:00 | |
No majic | 01/01/70 00:00 | |
delay | 01/01/70 00:00 | |
Writing Timing Loops in C | 01/01/70 00:00 | |
Lucky | 01/01/70 00:00 | |
Very true! | 01/01/70 00:00 | |
Your adc value must be 123. { | 01/01/70 00:00 | |
Power Supply Problem | 01/01/70 00:00 | |
We can not see what you are looking at | 01/01/70 00:00 | |
current limiting power supply? | 01/01/70 00:00 | |
Power Supply | 01/01/70 00:00 | |
Power Supply | 01/01/70 00:00 | |
ADC0804 with 8051 | 01/01/70 00:00 | |
Start a new thread! | 01/01/70 00:00 | |
Sorry Dude!!!![]() | 01/01/70 00:00 |