Skip to content

Instantly share code, notes, and snippets.

@danibyay
Created September 14, 2016 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danibyay/b975eae46ab6172d80c3aba61820c3a9 to your computer and use it in GitHub Desktop.
Save danibyay/b975eae46ab6172d80c3aba61820c3a9 to your computer and use it in GitHub Desktop.
/*
Program to use the ADC Module of the Freescale microcontroler S08QG8
Using 3 channels (GPIO)
*/
unsigned char ADC_value[3];
unsigned char ADC_sel[] = {0x60, 0x63, 0x66};
unsigned char i;
interrupt VectorNumber_Vadc void ADC_ISR (void)
{
ADCSC1 = ADC_sel[i];
ADC_value[i++] = ADCRL;
if( i == 3 )
{
i = 0;
}
}
void main ( void )
{
i = 0;
//activar 3 canales, 3 pines como entradas analogicas
APCTL1_ADPC0 = 1;
APCTL1_ADPC3 = 1;
APTL1_ADPC6 = 1;
ADCSC1 = 0b01100000; //para leer del canal cero
do
{
__RESET_WATCHDOG();
}while (1) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment