Description
Synchronous read of most significant 8 bits of analog channelPIC's such as the 16F876 have a built-in Analog to Digital Convertor (ADC). The ADC is connected to the outside world through analog input pins. These pins share functions with other peripherals. Before they can be used as analog inputs they must be configured as analog inputs using the ADC_init function.
The PIC ADC is 10 bits wide this means that an analog input can be digtised and read as a value between 0 and 1023.
10 bit values need to be processed as 16 bit words, 8 bit values can be efficiently processed as 8 bit bytes. This function reads the selected analog input channel using the 10 bit ADC and efficiently converts it to an 8 bits value before returning it.
Definition
ubyte ADC_read_8bit(ubyte channel_id)Library
LIB/adc_lib.basUsage
On entry:channel_id is the id of the analog channel to read. This corresponds to the PIC pin labelled ANj where channel_id is the index j and is in the range 0 to 7 (inclusive)On exit:e.g. if channel_id is 0 then pin AN0 (pin 2 of the 16f876) is read if channel_id is 4 then pin AN4 (pin 7 of the 16f876) is readsee ADC configuration for a more detailed description
return most significant 8 bits of ADC
return immediately with 0 is the channel is invalid