I just committed some changes to support Blackpill F401 in my repo.
Blinky works, and anything else should also work, as I tried a lot of interfaces of F411 which was used as base for F401.
Should anyone give it a try and find some problems, please open an issue in my repo.
Remarks:
- PB11 is missing from the LQFP48 package so I2C2 is not supported.
PS: Admin: feel free to move this post to any other better suited place if needed.
[LIBMAPLE] Support for blackpill F401 board
-
- Posts: 505
- Joined: Fri Dec 27, 2019 4:53 pm
- Location: Munich, Germany
- Contact:
Re: [LIBMAPLE] Support for blackpill F401 board
hi steve,
i think we need to rework the clock setting f4 code.
blackpill f411 runs on a 25mhz crystal
while
disco f411 runs on a 8mhz crystal
https://github.com/stevstrong/Arduino_S ... f411.h#L41
https://github.com/stevstrong/Arduino_S ... cF4.c#L277
my thoughts are either to do like the official core
the system clock config is defined in the variant itself
https://github.com/stm32duino/Arduino_C ... t.cpp#L106
or we can do something similar to libopencm3
we can have the variant maintain a structure containing some clock setups
https://github.com/libopencm3/libopencm ... /rcc.c#L52
and a call back function needs to be defined in the variant to return the structure, it can even be a static structure or class that needs to be defined in the variant, initialized at reset so that the rcc_init_clocks() would look for those values in that structure.
but i just thought that this approach may lead to ifdefs, while the variant call back can be a fixed function to return a fixed structure
i think we need to rework the clock setting f4 code.
blackpill f411 runs on a 25mhz crystal
while
disco f411 runs on a 8mhz crystal
https://github.com/stevstrong/Arduino_S ... f411.h#L41
https://github.com/stevstrong/Arduino_S ... cF4.c#L277
my thoughts are either to do like the official core
the system clock config is defined in the variant itself
https://github.com/stm32duino/Arduino_C ... t.cpp#L106
or we can do something similar to libopencm3
we can have the variant maintain a structure containing some clock setups
https://github.com/libopencm3/libopencm ... /rcc.c#L52
Code: Select all
{ /* 84MHz */
.pllm = 16,
.plln = 336,
.pllp = 4,
.pllq = 7,
...
but i just thought that this approach may lead to ifdefs, while the variant call back can be a fixed function to return a fixed structure
Re: [LIBMAPLE] Support for blackpill F401 board
HardwareTimer.setperiod(uint32_t usecs) is making it running 2 times too fast.
test sketch
this code use the timer to blink the led and print the seconds elapsed. the number of seconds is measured using millis() whcih is based on systick_uptime. systick is running at the correct 1ms intervals.
results
hence the timer is running at 2 Hz, when a 1 s period is specified
the fix is change
https://github.com/stevstrong/Arduino_S ... er.cpp#L57
to
test sketch
Code: Select all
#include <Arduino.h>
uint32_t start = 0;
void timerhandler() {
toggleLED();
int secs = (millis()-start)/1000;
Serial.println(secs);
}
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, 0);
SerialUSB.begin();
start = millis();
Timer1.init();
Timer1.setPeriod(1000000);
Timer1.attachInterrupt(0, timerhandler);
Timer1.refresh();
Timer1.resume();
}
void loop() {
asm("wfi");
}
results
Code: Select all
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
the fix is change
https://github.com/stevstrong/Arduino_S ... er.cpp#L57
Code: Select all
uint16 HardwareTimer::setPeriod(uint32 microseconds)
...
uint32 period_cyc = microseconds * (CYCLES_PER_MICROSECOND / 2);
...
Code: Select all
uint16 HardwareTimer::setPeriod(uint32 microseconds)
...
uint32 period_cyc = microseconds * (CYCLES_PER_MICROSECOND );
...
-
- Posts: 505
- Joined: Fri Dec 27, 2019 4:53 pm
- Location: Munich, Germany
- Contact:
-
- Posts: 505
- Joined: Fri Dec 27, 2019 4:53 pm
- Location: Munich, Germany
- Contact:
Re: [LIBMAPLE] Support for blackpill F401 board
Regarding the RCC, I also had thoughts on it, I may use something similar to libopencm3.
Thanks for opening an issue, I will work on it.
Thanks for opening an issue, I will work on it.
Re: [LIBMAPLE] Support for blackpill F401 board
Damm ... So my enhancement has been a waste of time
viewtopic.php?p=747#p747
Well Steve .. You could apply the patch , while you're "thinking" about the "golden solution"
I did use libopencm3 for my F411 board , but as ie. 96MHz wasn't in i had to do a "local" struct , and use that.
What i mean is there's prob. no "One fits all"
/Bingo


viewtopic.php?p=747#p747
Well Steve .. You could apply the patch , while you're "thinking" about the "golden solution"
I did use libopencm3 for my F411 board , but as ie. 96MHz wasn't in i had to do a "local" struct , and use that.
What i mean is there's prob. no "One fits all"
/Bingo