motor controller

Dependencies:   mbed plotter

Revision:
7:ed19a937daa0
Parent:
4:4e00b310811d
--- a/io.cpp	Sat Nov 05 20:20:48 2016 +0000
+++ b/io.cpp	Sun Nov 06 03:09:28 2016 +0000
@@ -104,9 +104,12 @@
     /************************************
                 ADC/DAC START
     *************************************/
+    //     RCC->APB1ENR |= 0x20000000; // Enable clock for DAC
+    // DAC->CR |= 0x00000001; // DAC control reg, both channels ON
+     GPIOA->MODER |= 0x00000300; // PA04 as analog output   
     ADC1->CR2 |= ADC_CR2_ADON; //adc 1 on
     ADC2->CR2 |= ADC_CR2_ADON; //adc 2 on
-    DAC->CR   |= DAC_CR_EN2;   //dac 2 (PA5) on
+    //DAC->CR   |= DAC_CR_EN2;   //dac 2 (PA5) on
     
     //get_serial(0)->printf("Turning on TIMER\n");
     /************************************
@@ -137,7 +140,7 @@
  
     TIM2->CR1   = 0x0001;
     TIM2->SMCR  = TIM_ENCODERMODE_TI12;
-    TIM2->CCMR1 = 0xf1f1;
+    TIM2->CCMR1 = 0x0101;
     TIM2->CCMR2 = 0x0000;
     TIM2->CCER  = 0x0011;
     TIM2->PSC   = 0x0000;
@@ -223,13 +226,16 @@
     return size; //we finished the loop so buffer is full, all bytes read.
 }
 
+
 //interrupt handler for encoder index
 void handle_index()
 {
     if (index_in->read())
     {
         if(index_in->read())
-            TIM2->CNT=0;
+        {
+                TIM2->CNT=0;
+        }
     }
 }