From d92157c81b0b8e8f3b4e04083b036d58a6478363 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Wed, 24 May 2023 17:50:18 +0200 Subject: [PATCH] fix readback of voltage adjustment, show raw reply in software --- atmega32u4/dcdc_mdc/main.c | 10 ++++++++-- atmega32u4/dcdc_mdc/mdc_powerboard.pl | 15 +++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/atmega32u4/dcdc_mdc/main.c b/atmega32u4/dcdc_mdc/main.c index 1cc5fdc..5c9c5a9 100644 --- a/atmega32u4/dcdc_mdc/main.c +++ b/atmega32u4/dcdc_mdc/main.c @@ -90,7 +90,7 @@ void getdata(uint8_t buf); /* * #################################### define parameters to fixed values */ -#define FIRMWARE_VERSION 0x001 +#define FIRMWARE_VERSION 0x002 #define ISMYADDR() (rxbuf[1] == '0' && rxbuf[2] == '0') @@ -321,6 +321,8 @@ ISR(ADC_vect) { ADMUX &= 0xe0; ADMUX |= (channel & 0x7); +// if(channel == 5) +// ADMUX |= 0x10; //differential for temperature if (channel >= 10) ADCSRB |= (1 << MUX5); else @@ -342,11 +344,14 @@ ISR(USART1_RX_vect) { ISR(USART1_UDRE_vect) { // interupt for transmitting answer message - if (txbuf[txpoint] != 0) + if (txbuf[txpoint] != 0) { UDR1 = txbuf[txpoint++]; + LED2_ON(); + } if (txpoint > 11 || txbuf[txpoint] == 0) { txpoint = 0; UCSR1B &= ~(1 << UDRIE1); // deactivate Transmit + LED2_OFF(); } } @@ -476,6 +481,7 @@ void getdata(uint8_t buf) { if (hex_to_int(rxbuf[4]) == 1) { read_setting = 7 - ((shift_register >> (hex_to_int(rxbuf[3]) * 8)) & 7); } + read_setting = ((read_setting >> 2) & 1) | (read_setting & 2) | ((read_setting << 2) & 4); send_answer_hex(&rxbuf[0], read_setting); } diff --git a/atmega32u4/dcdc_mdc/mdc_powerboard.pl b/atmega32u4/dcdc_mdc/mdc_powerboard.pl index 7a791a5..5d72fbe 100755 --- a/atmega32u4/dcdc_mdc/mdc_powerboard.pl +++ b/atmega32u4/dcdc_mdc/mdc_powerboard.pl @@ -107,16 +107,19 @@ sub PrintAnswerNice { my $outp = hex(substr($s,3,1)); my $uC = hex(substr($s,1,2)); my $answ = hex(substr($s,6)); - print $s."\n"; - print "-----------------------------------------------\n"; - print "Board: ".$uC."\t"; - print "Output: ".$outp."\t"; - print "Channel: ".$ch."\n"; - print "-----------------------------------------------\n"; + if ($SEL_rw == 1 && $answ == 0x00d1) { print "Done.\n"; return; } + + print "-----------------------------------------------\n"; + print "Board: ".$uC."\t"; + print "Output: ".$outp."\t"; + print "Channel: ".$ch."\t"; + print "Reply: ".$s."\n"; + print "-----------------------------------------------\n"; + if ($command == 0) { # Switch print "Output active.\n" if $answ == 1; print "Output off.\n" if $answ == 0; -- 2.43.0