http://chibios.sourceforge.net/html/group___t_m.html
For that function I believe I would basically need to setup a task, which could trigger every 0.01mS, which would then do the pseudo code posted below.
Now = pin state
If last = 0 and now = 1, then
stop timer,
save time,
restart timer,
Set flag that new time has been captured for processing.
last = now
I don't like this because the min increment is 0.01mS. I know that the timers are operating with a 8MHz clock, if I could connect the pin to the timer IRQ, then I could get a minimum increment of 0.000125mS. In my case a time of 2.03mS is 117.3 RPM, while 2.04mS is 116.7. That tolerance is more than I would prefer, it would cause some problems else where in the system. If I could 0.001mS I would probably be good, but 0.01mS is not enough.I tried pushing the Chibios tick time to 0.001mS, but it seemed to become unstable. I suspect there was to much overhead and not enough time to allow tasks to operate. I didn't dig into it very much, just backed up up to 0.01mS and it all seemed to work as expected.
Is there an example of how to configure a timer connecting a MCU pin to an TIM IRQ? I'm using an STM32F429. I'm hoping I can connect TIM3_CH1 to PB4 and TIM4_CH2 to PB7. However I don't know how to set the pins to start and stop the timer. I know that functions like pwmStart exist for when you are using these timers as a PWM, but I'm not sure if functions exist for other timer features. I don't know how to configure it for input capture vs PWM output. I know for PWM output you use these functions.
pwmStart to initialize the PWM driver with clock scales and such determined by PWMConfig
pwmEnableChannel to do the actual PWM.
I'm not finding initialization functions for the input capture modes of operation. Do they exist? Am I simply not finding them?
In board.h I have set the below.
Code: Select all
#define VAL_GPIOB_MODER (PIN_MODE_ALTERNATE(GPIOB_LCD_R3) | \
PIN_MODE_ALTERNATE(GPIOB_PIN4) | \
PIN_MODE_ALTERNATE(GPIOB_PIN7) | \
PIN_MODE_ALTERNATE(GPIOB_OTG_HS_DP))
#define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_LCD_R3) | \
PIN_PUPDR_FLOATING(GPIOB_PIN4) | \
PIN_PUPDR_FLOATING(GPIOB_PIN7) | \
PIN_OTYPE_PUSHPULL(GPIOB_OTG_HS_DP))
define VAL_GPIOB_OSPEEDR (PIN_OSPEED_100M(GPIOB_LCD_R3) | \
PIN_OSPEED_100M(GPIOB_PIN4) | \
PIN_OSPEED_100M(GPIOB_PIN7) | \
PIN_OSPEED_100M(GPIOB_OTG_HS_DP))
#define VAL_GPIOB_PUPDR (PIN_PUPDR_FLOATING(GPIOB_LCD_R3) | \
PIN_PUPDR_PULLUP(GPIOB_PIN4) | \
PIN_PUPDR_PULLUP(GPIOB_PIN7) | \
PIN_PUPDR_FLOATING(GPIOB_OTG_HS_DP))
#define VAL_GPIOB_ODR (PIN_ODR_HIGH(GPIOB_LCD_R3) | \
PIN_ODR_HIGH(GPIOB_PIN4) | \
PIN_ODR_HIGH(GPIOB_PIN7) | \
PIN_ODR_HIGH(GPIOB_OTG_HS_DP))
#define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_LCD_R3, 14) | \
PIN_AFIO_AF(GPIOB_PIN4, 2) | \
PIN_AFIO_AF(GPIOB_PIN7, 2))