diff --git a/include/dac.h b/include/dac.h
index 3c6de961852e36bcd0d50d18da55e9485ef6e95d..45b7f3b897eb7ae5c68c80ea925f7b7fb6c8afeb 100644
--- a/include/dac.h
+++ b/include/dac.h
@@ -4,7 +4,7 @@
 #include <avr/io.h>
 #include <avr/interrupt.h>
 
-typedef enum {dac0,dac1} dac_ch_t;
+typedef enum {dac0=0,dac1=1} dac_ch_t;
 
 void dac_init(void);
 void dac_start(void);
diff --git a/include/memory_map.h b/include/memory_map.h
index 0ed68116f4e38f6793768990075ec2e15c6e5b7e..9c1ea1c663fd86de969b8719c7de0dfda61d7011 100644
--- a/include/memory_map.h
+++ b/include/memory_map.h
@@ -14,7 +14,7 @@
 #define ADC_CONTROL               0x20   //32 - 0x20 R/W  ADC control  bit 7 | bit 6 | bit 5 | bit 4 | bit 3 |  bit 2  | bit 1 | bit 0
                                          //                                                                    running   stop    start
 #define ADC_NUM_SAMPLES           0x21   //33 - 0x21 R/W  Number of sample to average
-#define ADC_SAMPLE_PERIOD         0x21   //33 - 0x21 R/W  ADC sample period in ms
+#define ADC_SAMPLE_PERIOD         0x22   //33 - 0x22 R/W  ADC sample period in ms
 #define GPIO0_config              0x30   //48 - 0x30 R/W  GPIO 0 configuration bit 7 | bit 6 | bit 5 | bit 4 | bit 3 | bit 2 | bit 1 | bit 0
                                          //                                                                                            mode (0 -> input, 1 -> output)
 #define GPIO0_data                0x31   //49 - 0x31 R/W  GPIO 0 data bit 7 | bit 6 | bit 5 | bit 4 | bit 3 | bit 2 | bit 1 | bit 0
diff --git a/include/pwm.h b/include/pwm.h
index 0e7bb39d9696994db1c6bd6d39cc629619cc1e82..f63ca7bdfbf3d02fb13793c7221b14f869ae5db7 100644
--- a/include/pwm.h
+++ b/include/pwm.h
@@ -4,7 +4,7 @@
 #include <avr/io.h>
 #include <avr/interrupt.h>
 
-typedef enum {pwm0,pwm1,pwm2,pwm3} pwm_id_t;
+typedef enum {pwm0=0,pwm1=1,pwm2=2,pwm3=3} pwm_id_t;
 
 void pwm_init(void);
 void pwm_start(void);
diff --git a/src/dyn_common.c b/src/dyn_common.c
index 627e03b655309448e92e44e38ce6e55dcc8dda69..dcf85a415b3e869f5a73f7df438bfed6ab62573b 100644
--- a/src/dyn_common.c
+++ b/src/dyn_common.c
@@ -43,9 +43,9 @@ uint8_t do_write(uint8_t address,uint8_t length,uint8_t *data)
     else if(i==ADC_CONTROL)
     {
       if(data[num]&0x01)
-        adc_stop();
-      else if(data[num]&0x02)
         adc_start();
+      else if(data[num]&0x02)
+        adc_stop();
     }
     else if(i==ADC_NUM_SAMPLES)
       adc_set_num_samples(data[num]);
@@ -71,7 +71,7 @@ uint8_t do_write(uint8_t address,uint8_t length,uint8_t *data)
         pwm_disable_ch(pwm1);
       if(data[num]&0x04)
         pwm_enable_ch(pwm2);
-      else if(data[num]&0x40);
+      else if(data[num]&0x40)
         pwm_disable_ch(pwm2);
       if(data[num]&0x08)
         pwm_enable_ch(pwm3);
@@ -96,7 +96,7 @@ uint8_t do_write(uint8_t address,uint8_t length,uint8_t *data)
     {
       if(data[num]&0x01)
         dac_enable_channel(dac0);
-      else if(data[num]&0x04);
+      else if(data[num]&0x04)
         dac_disable_channel(dac0);
       if(data[num]&0x02)
         dac_enable_channel(dac1);
diff --git a/src/pwm.c b/src/pwm.c
index 4e82601aab1c9978b8af724dca522656cb286108..3d882ca6acfafee9adabf68616d36f7f8a295bc3 100644
--- a/src/pwm.c
+++ b/src/pwm.c
@@ -1,5 +1,6 @@
 #include "pwm.h"
 #include "mem.h"
+#include "ports.h"
 
 #define      DEFAULT_PWM_FREQ     50// Hz
 #define      DEFAULT_PWM_DUTY     50// %