- ADCCTL0 |= ADCSHT_2 | ADCON; // ADCON, S&H=16 ADC clks
- ADCCTL1 |= ADCSHP; // ADCCLK = MODOSC; sampling timer
- ADCCTL2 |= ADCRES; // 10-bit conversion results
- ADCMCTL0 |= ADCINCH_7; // A7 ADC input select; Vref=AVCC
- ADCIE |= ADCIE0; // Enable ADC conv complete interrupt
+
+#ifdef ADCPCTL4 /* Newer model */
+ SYSCFG2 |= ADCPCTL4|ADCPCTL5; // disconnect pin 4 and 5 from GPIO
+ ADCCTL0 |= ADCSHT_2 | ADCON; // ADCON, S&H=16 ADC clks
+ ADCCTL1 |= ADCSHP; // ADCCLK = MODOSC; sampling timer
+ ADCCTL2 |= ADCRES; // 10-bit conversion results
+ ADCMCTL0 |= ADCINCH_4; // A4 ADC input select; Vref=AVCC
+ ADCIE |= ADCIE0; // Enable ADC conv complete interrupt
+ // channel 5 is unused, reserved for measuring current
+#else
+ ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE; // ADCON, S&H=16 ADC clks
+ ADC10CTL1 = INCH_4; // A4 ADC input select
+ // channel 5 is unused, reserved for measuring current
+#endif
+
+ // Timer and PWM
+
+#ifndef TASSEL__SMCLK
+# define TASSEL__SMCLK TASSEL_2
+# define MC__UP MC_1
+# define MC__CONTINUOUS MC_2
+# define TA0CCR2 TA0CCR1
+# define TA0CCTL2 TA0CCTL1
+#endif