For LIGHT

Dependencies:   mbed FastPWM

Revision:
20:806196fda269
Parent:
15:bd0d12728506
Child:
21:e5f1a43ea6f9
--- a/INIT_HW/INIT_HW.cpp	Mon Sep 09 06:29:56 2019 +0000
+++ b/INIT_HW/INIT_HW.cpp	Mon Sep 09 06:57:31 2019 +0000
@@ -66,11 +66,29 @@
     TIM3->CR1 |= TIM_CR1_ARPE;                                  // autoreload on, 
     TIM3->RCR |= 0x001;                                         // update event once per up/down count of TIM3 
     TIM3->EGR |= TIM_EGR_UG;
- 
-    //PWM Setup
 
     TIM3->PSC = 0x0;                                            // no prescaler, timer counts up in sync with the peripheral clock
     TIM3->ARR = TMR3_COUNT;                                          // set auto reload, 5 khz
     TIM3->CCER |= ~(TIM_CCER_CC1NP);                            // Interupt when low side is on.
     TIM3->CR1 |= TIM_CR1_CEN;                                   // enable TIM4
+}
+
+void Init_TMR5(){
+    RCC->APB1ENR |= RCC_APB1ENR_TIM5EN;                         // enable TIM5 clock
+    
+     //ISR Setup     
+    
+    NVIC_EnableIRQ(TIM5_IRQn);                         //Enable TIM5 IRQ
+
+    TIM5->DIER |= TIM_DIER_UIE;                                 // enable update interrupt
+    TIM5->CR1 = 0x40;                                           // CMS = 10, interrupt only when counting up // Center-aligned mode
+    TIM5->CR1 |= TIM_CR1_UDIS;
+    TIM5->CR1 |= TIM_CR1_ARPE;                                  // autoreload on, 
+    TIM5->RCR |= 0x001;                                         // update event once per up/down count of TIM5
+    TIM5->EGR |= TIM_EGR_UG;
+
+    TIM5->PSC = 0x0012;                                            // no prescaler, timer counts up in sync with the peripheral clock
+    TIM5->ARR = TMR5_COUNT;                                          // set auto reload, 5 khz
+    TIM5->CCER |= ~(TIM_CCER_CC1NP);                            // Interupt when low side is on.
+    TIM5->CR1 |= TIM_CR1_CEN;                                   // enable TIM5
 }
\ No newline at end of file