From a04c9c9a65eda73ce5b365a5a8adce807f8d1443 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Sun, 20 May 2012 02:42:45 +0000 Subject: adc on/off git-svn-id: https://svn.spreadspace.org/mur.sat@449 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- software/hhd70dongle/hhd70dongle.c | 3 +++ software/hhd70dongle/util.c | 17 ++++++++++++----- software/hhd70dongle/util.h | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) (limited to 'software') diff --git a/software/hhd70dongle/hhd70dongle.c b/software/hhd70dongle/hhd70dongle.c index bc62dea..9bf3e8b 100644 --- a/software/hhd70dongle/hhd70dongle.c +++ b/software/hhd70dongle/hhd70dongle.c @@ -106,6 +106,8 @@ int main(void) write_buffer[3]='p'; write_buffer[4]='s'; write_buffer[5]=':'; + adc_on(); + _delay_ms(250); usb_rawhid_send((uint8_t*)"temp c1101:",255); debug_sprint_int16hex(write_buffer+6, c1101_measureTemp()); usb_rawhid_send(write_buffer+6,255); @@ -113,6 +115,7 @@ int main(void) usb_rawhid_send((uint8_t*)"temp atmega:",255); debug_sprint_int16hex(write_buffer+10, adc_read(ADCMUX_ADC12)); usb_rawhid_send(write_buffer+10,255); + adc_off(); _delay_ms(250); led_on(); usb_rawhid_send((uint8_t*)"TX Data: String",255); diff --git a/software/hhd70dongle/util.c b/software/hhd70dongle/util.c index 2c358fa..56fe575 100644 --- a/software/hhd70dongle/util.c +++ b/software/hhd70dongle/util.c @@ -70,19 +70,26 @@ void reset(void) #endif } +//not switchin off adc produces slightly besser results +void adc_on(void) +{ + ADCSRA = (1< save power +} + + uint8_t adc_read(uint8_t mux) { ADCSRB = (mux & 0x20); // select input ADMUX = 0b11100000 | (mux & 0x1F); // select input cont'd // select internal 2.56V reference, // result is left justified - ADCSRA = (1< save power - return ADCH; } diff --git a/software/hhd70dongle/util.h b/software/hhd70dongle/util.h index 20068fd..4554af9 100644 --- a/software/hhd70dongle/util.h +++ b/software/hhd70dongle/util.h @@ -37,6 +37,8 @@ #define ADCMUX_ADC12 0b00100100 void reset(void); +void adc_on(void); +void adc_off(void); uint8_t adc_read(uint8_t mux); void debug_sprint_int16hex(uint8_t *buffer, int16_t num); -- cgit v1.2.3