Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned int read_analog_channel(int channel)
- {
- ADCHS = channel; // channal is the input analoge
- ADCSSL = 0;
- ADCON3 = 0x0205; // Manual Sample, ADCS=5 -> Tad = 3*Tcy = 0.1us
- ADCON2 = 0; // one sample
- ADCON1bits.ADON = 1; // turn ADC ON
- ADCON1bits.SAMP = 1; // start sampling then ...
- // after 3Tad go to conversion
- while (!ADCON1bits.DONE); // conversion done?
- ADC value = ADCBUF0
Add Comment
Please, Sign In to add comment