From 1aa694bba2833db6f1c5b05b7bcd29f8d57736f3 Mon Sep 17 00:00:00 2001 From: Ralf Schlatterbeck Date: Mon, 30 Jun 2014 14:25:33 +0200 Subject: [PATCH] Turn off JTAG in adc_init --- platform/osd-merkur/dev/adc.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/platform/osd-merkur/dev/adc.h b/platform/osd-merkur/dev/adc.h index 6ea4cf0ab..e3ff516b1 100644 --- a/platform/osd-merkur/dev/adc.h +++ b/platform/osd-merkur/dev/adc.h @@ -39,9 +39,22 @@ static inline void adc_fin (void) static inline void adc_init (void) { + uint8_t temp; ADCSRC = 0; ADCSRB = 0; adc_fin (); + /* + * Disable JTAG interface + * Hardware manual about JTD bit: + * "In order to avoid unintentional disabling or enabling of the + * JTAG interface, a timed sequence must be followed when changing + * this bit: The application software must write this bit to the + * desired value twice within four cycles to change its value." + * 15.4.1 "MCUCR - MCU Control Register", p. 219 + */ + temp = MCUCR | (1 << JTD); + MCUCR = temp; + MCUCR = temp; } int readADC(uint8_t pin);