Modified Motor Driver Firmware to include Flash + Thermal
Dependencies: FastPWM3 mbed-dev-STM-lean
Diff: main.cpp
- Revision:
- 2:8724412ad628
- Parent:
- 1:b8bceb4daed5
- Child:
- 3:6a0015d88d06
diff -r b8bceb4daed5 -r 8724412ad628 main.cpp --- a/main.cpp Fri Feb 05 01:04:57 2016 +0000 +++ b/main.cpp Fri Feb 19 04:13:06 2016 +0000 @@ -7,17 +7,20 @@ #include "CurrentRegulator.h" PositionSensorEncoder encoder(8192,0); -Inverter inverter(PA_5, PB_10, PB_3, PB_7, 0.02014160156, 0.00005); +//Inverter inverter(PA_5, PB_10, PB_3, PB_7, 0.02014160156, 0.00005); +Inverter inverter(PA_8, PA_9, PA_10, PB_7, 0.02014160156, 0.00005); CurrentRegulator foc(&inverter, &encoder, .005, .5); Ticker testing; + using namespace FastMath; using namespace Transforms; //float offset = 0;//-0.24; // Current Sampling IRQ +/* extern "C" void TIM2_IRQHandler(void) { // flash on update event if (TIM2->SR & TIM_SR_UIF & TIM2->CNT>0x465) { @@ -25,6 +28,15 @@ } TIM2->SR = 0x0; // reset the status register } +*/ +extern "C" void TIM1_UP_TIM10_IRQHandler(void) { + // toggle on update event + if (TIM1->SR & TIM_SR_UIF ) { + inverter.SampleCurrent(); + } + TIM1->SR = 0x0; // reset the status register + //GPIOC->ODR ^= (1 << 4); //Toggle pin for debugging +} void Loop(void){ @@ -44,9 +56,10 @@ wait(1); testing.attach(&Loop, .0001); + //inverter.SetDTC(.2, .5, .97); //inverter.EnableInverter(); while(1) { - + } }