Guest User

Untitled

a guest
Feb 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. unsigned int read_analog_channel(int channel)
  2. {
  3. ADCHS = channel; // channal is the input analoge
  4. ADCSSL = 0;
  5. ADCON3 = 0x0205; // Manual Sample, ADCS=5 -> Tad = 3*Tcy = 0.1us
  6. ADCON2 = 0; // one sample
  7. ADCON1bits.ADON = 1; // turn ADC ON
  8. ADCON1bits.SAMP = 1; // start sampling then ...
  9. // after 3Tad go to conversion
  10. while (!ADCON1bits.DONE); // conversion done?
  11. ADC value = ADCBUF0
Add Comment
Please, Sign In to add comment