STM32F1xx
STM32F1xx copied to clipboard
PA1 for spindle pwm out ?
Can we use PA1 instead of PA8 as spindle pwm output?
Seems it is possible, from PA1 spec: USART2_RTS(9)/ADC12_IN1/TIM2_CH2(9)
driver.h must be modified for that, STEPPER_TIMER
has to be changed as well as it is mapped to timer 2.
You can do it?
I will try to do it. If I am not successful, I will inform you,
Seems it is possible, from PA1 spec:
USART2_RTS(9)/ADC12_IN1/TIM2_CH2(9)
driver.h must be modified for that,STEPPER_TIMER
has to be changed as well as it is mapped to timer 2.You can do it?
I have modified the driver.h file for SPINDLE PWM on PA1, gives output when SPINDLE_PWM_TIMER_INV set to 1, output does not work when set to 0
// Define timer allocations. #define STEPPER_TIMER TIM5 #define PULSE_TIMER TIM3 #define DEBOUNCE_TIMER TIM4
#ifdef SPINDLE_PWM_PORT_BASE
#if SPINDLE_PWM_PORT_BASE == GPIOA_BASE #if SPINDLE_PWM_PIN == 1 // PA1 - TIM2_CH2 #define SPINDLE_PWM_TIMER_N 2 #define SPINDLE_PWM_TIMER_CH 2 #define SPINDLE_PWM_TIMER_INV 1 #define SPINDLE_PWM_AF_REMAP 0 #endif #if SPINDLE_PWM_PIN == 8 // PA8 - TIM1_CH1 #define SPINDLE_PWM_TIMER_N 1 #define SPINDLE_PWM_TIMER_CH 1 #define SPINDLE_PWM_TIMER_INV 0 #define SPINDLE_PWM_AF_REMAP 0 #endif #elif SPINDLE_PWM_PORT_BASE == GPIOB_BASE #if SPINDLE_PWM_PIN == 0 // PB0 - TIM1_CH2N #define SPINDLE_PWM_TIMER_N 1 #define SPINDLE_PWM_TIMER_CH 2 #define SPINDLE_PWM_TIMER_INV 1 #define SPINDLE_PWM_AF_REMAP 0b01 #endif #endif
I want normal output of this signal
I have modified the driver.h file for SPINDLE PWM on PA1, gives output when SPINDLE_PWM_TIMER_INV set to 1, output does not work when set to 0
That is a bit odd, is this with a cloned MCU or genuine one?
I want normal output of this signal
The scope trace does not tell me anything. What is wrong with it? Should it be 5KHz?
The scope trace does not tell me anything. What is wrong with it? Should it be 5KHz?
I guess I didn't fully explain the problem. The output of the oscilloscope indicates that the output of the generated signal is inverted. The expected signal should be invertesd to the signal on the oscilloscope, how should we set it up?
The generated PWM signal should be a signal for the BESC spindle as shown below appears on the oscilloscope.
expexted pwm out signal
That is a bit odd, is this with a cloned MCU or genuine one?
real mcu, i am using BTT SKR MINI E3 V2.0 3D printer board
$16=4
works? ($$=16
for info)
$16=4
works? ($$=16
for info)
$16=4 ,I did nothing changed $$=16 0 - Spindle enable (1) 1 - Spindle direction (2) 2 - PWM (4) Inverts the spindle on, counterclockwise and PWM signals (active low).
#define SPINDLE_PWM_TIMER_INV 1
when SPINDLE_PWM_TIMER_INV set to 0 #define SPINDLE_PWM_TIMER_INV 0
no pwm output on PA1
There is a nasty bug here, wonder if it is this that trips it up for PA1? The line should be:
SPINDLE_PWM_TIMER->CCER |= SPINDLE_PWM_CCER_EN;
There is a nasty bug here, wonder if it is this that trips it up for PA1? The line should be:
SPINDLE_PWM_TIMER->CCER |= SPINDLE_PWM_CCER_EN;
good catch, it works now. that is, we can use two different pins (PA1 and PA8) for the pwm spindle output on the BTT SKR MINI E3 V2.0 3D printer board. in driver.h latest revision code as below
// Define timer allocations. #define STEPPER_TIMER TIM2 #define PULSE_TIMER TIM3 #define DEBOUNCE_TIMER TIM4
#ifdef SPINDLE_PWM_PORT_BASE
#if SPINDLE_PWM_PORT_BASE == GPIOA_BASE #if SPINDLE_PWM_PIN == 1 // PA1 - TIM5_CH2 #define SPINDLE_PWM_TIMER_N 5 #define SPINDLE_PWM_TIMER_CH 2 #define SPINDLE_PWM_TIMER_INV 0 #define SPINDLE_PWM_AF_REMAP 0 #endif #if SPINDLE_PWM_PIN == 8 // PA8 - TIM1_CH1 #define SPINDLE_PWM_TIMER_N 1 #define SPINDLE_PWM_TIMER_CH 1 #define SPINDLE_PWM_TIMER_INV 0 #define SPINDLE_PWM_AF_REMAP 0 #endif #elif SPINDLE_PWM_PORT_BASE == GPIOB_BASE #if SPINDLE_PWM_PIN == 0 // PB0 - TIM1_CH2N #define SPINDLE_PWM_TIMER_N 1 #define SPINDLE_PWM_TIMER_CH 2 #define SPINDLE_PWM_TIMER_INV 1 #define SPINDLE_PWM_AF_REMAP 0b01 #endif #endif