Line: 1 to 1 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
%DASHBOARD{ section="banner" | ||||||||||
Line: 6 to 6 | ||||||||||
title="Board Support Package for the STM32WB Feather Development Board" titlestyle="color:#F00000;" }% | ||||||||||
Changed: | ||||||||||
< < | Intro
| |||||||||
> > | Intro
| |||||||||
The board support package for the STM32WB Feather Development Board (see https://www.reclaimerlabs.com/stm32wb-feather![]() ![]() | ||||||||||
Changed: | ||||||||||
< < | Contents
| |||||||||
> > | Contents
| |||||||||
| ||||||||||
Line: 73 to 73 | ||||||||||
dport! ( n -- ) sets the digital output port (D0=bit0 .. D15=bit15). dport@ ( -- n ) gets the digital input/output port (D0=bit0 .. D15=bit15). | ||||||||||
Changed: | ||||||||||
< < | dpin! ( n a -- ) sets the digital output port pin a (D0=0 .. D15=15, A0=16 .. A6=23) | |||||||||
> > | dpin! ( n a -- ) sets the digital output port pin a (D0=0 .. D15=15, A0=16 .. A6=22) | |||||||||
dpin@ ( a -- n ) gets the digital input/output port pin a dmod ( u a -- ) sets the pin mode: 0 in, 1 in pull-up, 2 in pull-down, 3 out push pull, 4 out open drain, 5 out push pull PWM, 6 input capture, 7 output compare, 8 I2C, 9 USART, 10 analog | ||||||||||
Line: 245 to 245 | ||||||||||
Changed: | ||||||||||
< < | Six port pins are supported so far. The 16 bit timers TIM3 (D5 and D6) and TIM4 (D9, D10, D14, and D15) are used for the timebase, time resolution is 1 us (42 MHz SysClk divided by 42). The PWM scale is from 0 (0 % duty cycle) to 1000 (100 % duty cycle), this results in a PWM frequency of 1 kHz. If you need higher PWM frequencies, decrease the divider and/or the scale. | |||||||||
> > | Three port pins are supported so far. The 16 bit timer TIM1 (D0, D1, A4) is used for the timebase, time resolution is 1 us (32 MHz SysClk divided by 32). The PWM scale is from 0 (0 % duty cycle) to 1000 (100 % duty cycle), this results in a PWM frequency of 1 kHz. If you need higher PWM frequencies, decrease the divider and/or the scale. | |||||||||
Changed: | ||||||||||
< < | PWM port pins: D5 (TIM3CH2), D6 (TIM3CH1), D9 (TIM4CH3), D10 (TIM4CH4), D14 (TIM4CH2), and D15 (TIM4CH1). | |||||||||
> > | PWM port pins: D0 (TIM1CH3), D1 (TIM1CH2), and A4 (TIM1CH1). | |||||||||
Changed: | ||||||||||
< < | Simple test program to set brightness of a LED on pin D6 with a potentiometer on A0. Default PWM frequency is 1 kHz (prescaler set to 42). You can set the prescale with the word pwmprescale from 42 kHz (value 1) down to 0.5 Hz (64000). | |||||||||
> > | Simple test program to set brightness of a LED on pin D0 with a potentiometer on A0. Default PWM frequency is 1 kHz (prescaler set to 32). You can set the prescale with the word pwmprescale from 32 kHz (value 1) down to 0.5 Hz (64000). | |||||||||
Changed: | ||||||||||
< < | 5 6 dmod \ set D6 to PWM | |||||||||
> > | 5 0 dmod \ set D0 to PWM | |||||||||
: pwm ( -- ) begin | ||||||||||
Changed: | ||||||||||
< < | 0 apin@ 4 / 6 pwmpin! | |||||||||
> > | 0 apin@ 4 / 0 pwmpin! | |||||||||
10 osDelay drop key? until | ||||||||||
Line: 272 to 272 | ||||||||||
A servo pulse of 1.5 ms width will typically set the servo to its "neutral" position (typically half of the specified full range), a pulse of 1.0 ms will set it to 0°, and a pulse of 2.0 ms to 90° (for a 90° servo). The physical limits and timings of the servo hardware varies between brands and models, but a general servo's full angular motion will travel somewhere in the range of 90° – 180° and the neutral position (45° or 90°) is almost always at 1.5 ms. This is the "standard pulse servo mode" used by all hobby analog servos. | ||||||||||
Changed: | ||||||||||
< < | The BSPs default PWM frequency is 1 kHz, 50 Hz is 20 times slower. The divider is therefore 42 * 20 = 840. | |||||||||
> > | The BSPs default PWM frequency is 1 kHz, 50 Hz is 20 times slower. The divider is therefore 32 * 20 = 640. | |||||||||
| ||||||||||
Line: 287 to 287 | ||||||||||
| ||||||||||
Changed: | ||||||||||
< < | 840 pwmprescale 5 5 dmod \ set D5 to PWM | |||||||||
> > | 640 pwmprescale 5 0 dmod \ set D0 to PWM | |||||||||
: servo ( -- ) begin 130 40 do | ||||||||||
Changed: | ||||||||||
< < | i 5 pwmpin! | |||||||||
> > | i 0 pwmpin! | |||||||||
i neopixel! i 40 = if 1000 \ give some more time to get back | ||||||||||
Line: 332 to 332 | ||||||||||
Output Compare | ||||||||||
Changed: | ||||||||||
< < | Output compare TIM2: D0, D1 | |||||||||
> > | Output compare TIM2: D5, D6, and D13 | |||||||||
| ||||||||||
Changed: | ||||||||||
< < | 7 0 dmod \ output compare for D0 7 1 dmod \ output compare for D1 | |||||||||
> > | 7 5 dmod \ output compare for D5 7 6 dmod \ output compare for D6 7 13 dmod \ output compate for D13 | |||||||||
: oc-toggle ( -- ) 5000000 ICOCperiod! \ 5 s period ICOCstart | ||||||||||
Changed: | ||||||||||
< < | 3 0 OCmod 1000000 0 OCstart \ toggle D0 after 1 s 3 1 OCmod 2000000 1 OCstart \ toggle D1 after 2 s | |||||||||
> > | 3 5 OCmod 1000000 5 OCstart \ toggle D5 after 1 s 3 6 OCmod 2000000 5 OCstart \ toggle D6 after 2 s 3 13 OCmod 3000000 13 OCstart \ toggle D13 after 3 s | |||||||||
begin waitperiod cr .time | ||||||||||
Line: 353 to 355 | ||||||||||
When you abort (hit any key) the program, the timer still runs and controls the port pins. To stop the port pins:
| ||||||||||
Changed: | ||||||||||
< < | 0 OCstop 1 OCstop | |||||||||
> > | 5 OCstop 5 OCstop 13 OCstop | |||||||||
Or change the prescale to make it faster or slower: | ||||||||||
Line: 364 to 366 | ||||||||||
Input Capture | ||||||||||
Changed: | ||||||||||
< < | This sample program measures the time between the edges on port A1. if no event occurs within 2 seconds, "timeout" is issued. Hit any key to abort program. | |||||||||
> > | This sample program measures the time between the edges on port A5. if no event occurs within 2 seconds, "timeout" is issued. Hit any key to abort program. | |||||||||
: ic-test ( -- ) | ||||||||||
Changed: | ||||||||||
< < | 6 17 dmod \ input capture on A1 | |||||||||
> > | 6 21 dmod \ input capture on A5 | |||||||||
ICOCstart 2 ICstart \ both edges ICOCcount@ ( -- count ) | ||||||||||
Line: 398 to 400 | ||||||||||
Changed: | ||||||||||
< < | D11, D12, and D13 can be used as an EXTI line. EXTIs are external interrupt lines, D13 uses EXTI1 (EXTI Line1 interrupt), D12 EXIT2, and D11 EXTI3. | |||||||||
> > | D5, D6, D11 and D13 can be used as an EXTI line. EXTIs are external interrupt lines, D5 uses EXTI2 (EXTI Line2 interrupt), D6 EXTI3, D11 EXIT8, and D13 EXTI1. | |||||||||
: exti-test ( -- ) | ||||||||||
Changed: | ||||||||||
< < | 2 11 EXTImod \ both edges on D11 | |||||||||
> > | 2 5 EXTImod \ both edges on D5 | |||||||||
begin | ||||||||||
Changed: | ||||||||||
< < | 2000 11 EXTIwait \ wait for edge on D11 with 2 s timeout | |||||||||
> > | 2000 5 EXTIwait \ wait for edge on D5 (button C) with 2 s timeout | |||||||||
cr 0= if | ||||||||||
Changed: | ||||||||||
< < |
| |||||||||
> > |
| |||||||||
." rising edge" else ." falling edge" |