This example samples P00 using ADC continuous mode a rate of 2 Ksps and outputs the 8 bit sample value on P1.
Functions | |
| void | main () |
| ADC_ISR () | |
| void main | ( | void | ) |
Definition at line 31 of file main.c.
{
// Set P1 as output
P1DIR = 0;
// Configure ADC
hal_adc_set_input_channel(HAL_ADC_INP_AIN0);
hal_adc_set_reference(HAL_ADC_REF_VDD);
hal_adc_set_input_mode(HAL_ADC_SINGLE);
hal_adc_set_conversion_mode(HAL_ADC_CONTINOUS);
hal_adc_set_sampling_rate(HAL_ADC_2KSPS);
hal_adc_set_resolution(HAL_ADC_RES_8BIT);
hal_adc_set_data_just(HAL_ADC_JUST_RIGHT);
// Enable MISC interrupts to enable ADC interrupt
MISC = 1;
// Enable global interrupts
EA = 1;
// Start ADC conversion
hal_adc_start();
for(;;){}
}
| ADC_ISR | ( | ) |
Definition at line 56 of file main.c.
{
// Write sample value to P0
P1 = hal_adc_read_LSB();
}
1.7.2