From 9e311038c19feb05935ec3140e4914a49a23e904 Mon Sep 17 00:00:00 2001 From: Hakan Bastedt Date: Thu, 18 Jan 2024 17:21:12 +0100 Subject: [PATCH] TIM8 replaced with TIM3. TIM3,chan4 works on PC9. TIM8,chan4 should work but doesn't. How should one know? --- Firmware/src/StepGen.cpp | 2 +- Firmware/src/main.cpp | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Firmware/src/StepGen.cpp b/Firmware/src/StepGen.cpp index bedc44c..52fd1de 100755 --- a/Firmware/src/StepGen.cpp +++ b/Firmware/src/StepGen.cpp @@ -46,7 +46,7 @@ void StepGen::enable(uint8_t yes) void StepGen::handleStepper(void) { if (!enabled) - return; + return; actPos(timerStepPosition / double(stepsPerMM)); double diffPosition = reqPos() - actPos(); diff --git a/Firmware/src/main.cpp b/Firmware/src/main.cpp index c4ce843..ce76377 100755 --- a/Firmware/src/main.cpp +++ b/Firmware/src/main.cpp @@ -9,6 +9,7 @@ _Objects Obj; HardwareSerial Serial1(PA10, PA9); +#define DEBUG_TIM8 1 #include "MyEncoder.h" void indexPulseEncoderCB1(void); MyEncoder Encoder1(TIM2, PA2, indexPulseEncoderCB1); @@ -16,14 +17,6 @@ void indexPulseEncoderCB1(void) { Encoder1.indexPulse(); } -#if 0 -void indexPulseEncoderCB2(void); -MyEncoder Encoder2(TIM3, PB6, indexPulseEncoderCB2); -void indexPulseEncoderCB2(void) -{ - Encoder2.indexPulse(); -} -#endif #include "StepGen.h" void timerCallbackStep1(void); @@ -33,10 +26,10 @@ void timerCallbackStep1(void) Step1.timerCB(); } void timerCallbackStep2(void); -StepGen Step2(TIM8, 4, PC_9, PC10, timerCallbackStep2); +StepGen Step2(TIM3, 4, PC_9, PC10, timerCallbackStep2); void timerCallbackStep2(void) { - Step2.timerCB(); + //Step2.timerCB(); } void cb_set_outputs(void) // Master outputs gets here, slave inputs, first operation @@ -50,6 +43,7 @@ void cb_set_outputs(void) // Master outputs gets here, slave inputs, first opera Step2.reqPos(Obj.StepGenIn2.CommandedPosition); Step2.setScale(Obj.StepGenIn2.StepsPerMM); Step2.enable(Obj.Enable1); +# } void handleStepper(void) @@ -101,7 +95,6 @@ void setup(void) { Serial1.begin(115200); rcc_config(); // probably breaks some timers. - ecat_slv_init(&config); }