]> jspc29.x-matter.uni-frankfurt.de Git - avr.git/commitdiff
fix readback of voltage adjustment, show raw reply in software
authorJan Michel <michel@physik.uni-frankfurt.de>
Wed, 24 May 2023 15:50:18 +0000 (17:50 +0200)
committerJan Michel <michel@physik.uni-frankfurt.de>
Wed, 24 May 2023 15:50:18 +0000 (17:50 +0200)
atmega32u4/dcdc_mdc/main.c
atmega32u4/dcdc_mdc/mdc_powerboard.pl

index 1cc5fdcddbfd5faec2737e5a2d1a7abd2e11a431..5c9c5a9d17aa5a47aae3207304d1923ecc929488 100644 (file)
@@ -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);
         }
 
index 7a791a5a07ef9c897bbf34b8a11fcf37f6ebfda7..5d72fbe8ee0f6204527defd8e434294f126d7001 100755 (executable)
@@ -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;