Search found 9 matches

by rsonnicksen
Sun Apr 09, 2023 2:56 pm
Forum: General discussion
Topic: Rotary encoder with blue pill
Replies: 31
Views: 40413

Re: Rotary encoder with blue pill

@dannyf, Yes, I could poll the pins, but that would require my loop speed to be very fast. My encoder has 1024 pulses per revolution, so my loop time would need to be very short. Or, driving the polling with a timer would require the use of interrupts, which CAN be very useful, but I definitely try ...
by rsonnicksen
Thu Apr 06, 2023 6:56 pm
Forum: General discussion
Topic: Rotary encoder with blue pill
Replies: 31
Views: 40413

Re: Rotary encoder with blue pill

Here is the result of my tracing the functions in HardwareTimer #include "HardwareTimer.h" HardwareTimer MyTimer(4); MyTimer.pause(); //Disable timer CEN bit. MyTimer.setMode(1, TIMER_ENCODER ); //setMode(int channel, timer_mode mode) located in HardwareTimer.cpp //calls timer_set_mode(thi...
by rsonnicksen
Thu Apr 06, 2023 6:02 pm
Forum: General discussion
Topic: Rotary encoder with blue pill
Replies: 31
Views: 40413

Re: Rotary encoder with blue pill

Sigi, Thanks for the example code. I ran it on my Blue Pill and it worked correctly in ENCODER1 mode. Triggered on rise and fall of input channel 1. I changed MyTimer.setEdgeCounting(TIMER_SMCR_SMS_ENCODER1); to MyTimer.setEdgeCounting(TIMER_SMCR_SMS_ENCODER3); and it triggered on rise AND fall of B...
by rsonnicksen
Thu Apr 06, 2023 12:11 pm
Forum: General discussion
Topic: Rotary encoder with blue pill
Replies: 31
Views: 40413

Re: Rotary encoder with blue pill

Thanks, I'll give this a try. It looks like you're only triggering the counter on transitions of input channel1. MyTimer.setMode(1, TIMER_ENCODER ); MyTimer.setEdgeCounting(TIMER_SMCR_SMS_ENCODER1); I'm curious how this .setMode function works. I've traced it to. C:\Program Files (x86)\Arduino\hardw...
by rsonnicksen
Wed Apr 05, 2023 12:57 am
Forum: General discussion
Topic: Rotary encoder with blue pill
Replies: 31
Views: 40413

Re: Rotary encoder with blue pill

I have been struggling to get the hardware timers to work in encoder mode. I'm using a BluePill (STM32F103C8) and Roger Clarks core for Arduino. I'm setting it up in ENCODER3 mode (TIMER4_BASE->SMCR = TIMER_SMCR_SMS_ENCODER3; //SMS = 011) which according to the reference manual should trigger counts...
by rsonnicksen
Wed Dec 28, 2022 2:19 pm
Forum: STM boards (Discovery, Eval, Nucleo, ...)
Topic: [Solved] Can't remap Timer3 to PB4 on BluePill
Replies: 1
Views: 5237

Re: Can't remap Timer3 to PB4 on BluePill

Solved. Apparently the JTAG/SWO function is enabled by default, and this uses pins PA15, PB3 and PB4. I disabled this by writing 0b010 to the SWJ_CFG bits of the AFIO_MAPR register. So my working remap looks like this: //Configure Alternate Function Remap for Timers 2 and 3 to move them to 5V tolera...
by rsonnicksen
Wed Dec 28, 2022 1:22 pm
Forum: STM boards (Discovery, Eval, Nucleo, ...)
Topic: [Solved] Can't remap Timer3 to PB4 on BluePill
Replies: 1
Views: 5237

[Solved] Can't remap Timer3 to PB4 on BluePill

I've tried everything I can think of. I'm not good at locating non-Arduino functions in the Maple library, so I do a bit of direct register manipulation (using defines and enums from the library). I have timer3 running as output compare, and its generating a square wave on PA6 (T3C1). I want to move...
by rsonnicksen
Wed Dec 28, 2022 1:01 pm
Forum: Let us know a bit about you and your projects
Topic: Hello from Minnesota
Replies: 0
Views: 5246

Hello from Minnesota

I'm a mechanical engineer working in the industrial controls industry. I've built quad-copter flight controllers on the BluePill. I'm currently working on an aviation related project. I definitely need help with STM32 on Arduino to access some of the advanced functions of the MCU.
by rsonnicksen
Fri Dec 16, 2022 4:41 pm
Forum: LibMaple
Topic: STM32F103C8T6 Timer5
Replies: 1
Views: 4455

STM32F103C8T6 Timer5

According to the RM0008 STM32 F1 Reference Manual which in the General-purpose timers (TIM2 to TIM5) section states "This Section applies to the whole STM32F10xxx family, unless otherwise specified." I would expect the STM32F103C8T6 (BluePill) to include TIMER5. However, I see that this ti...

Go to advanced search