Spark Logic

[libmaple] Black F407VET6

stevestrong

The master branch of my repo contains the latest developments for F4, so I recommend to use this if somebody wants to test it with Arduino IDE or PlatformIO.
Supported board variants: generic F4 (tested), generic F4 mini (tested), disco F407 (compiles but not tested).

Some basic information about the board can be found on wiki: http://wiki.stm32duino.com/index.php?title=STM32F407

Currently working:
– GPIOs + LED toggle
– USB serial and serial 1,2,3. Evaluated USB serial speed, Tx: ~800kBps
– SPI (1,2,3) with DMA (also for SD cards using latest SdFat lib made by Greiman), extended DMA functions
– FSMC (adapted for driving 16 bit parallel LCDs) http://stm32duino.com/viewtopic.php?f=39&t=2298#p31037
– SDIO [non-HAL implementation] (for SD cards using latest SdFat lib made by Greiman) http://stm32duino.com/viewtopic.php?f=39&t=2215
– RTC – reworked, does not need any extra time library
– I2C (Wire) viewtopic.php?f=39&t=2804&p=37376#p37376
– supports W5500-based Ethernet modules (see viewtopic.php?f=13&t=503&p=32063#p32063)
– DAC, see viewtopic.php?f=39&t=1976&p=41564#p41564
– ADC, see http://stm32duino.com/viewtopic.php?f=3 … 720#p42720
– DCMI, see viewtopic.php?f=39&t=3414&p=43358#p43358
– CAN, see: http://stm32duino.com/viewtopic.php?f=3 … 239#p49235

Todo:
– port the new (faster) version of SDIO from Victor (https://github.com/rogerclarkmelbourne/ … 2/pull/474)
– check the on-board W25Q64 SPI flash, maybe add SPIflash lib to repo (where from?) https://github.com/LowPowerLab/SPIFlash
– check/add FPU (http://stm32duino.com/viewtopic.php?f=39&t=2001, http://stm32duino.com/viewtopic.php?f=3 … 048#p31040)
– add support for Seed Arch Max board
– add Ethernet lib (usable with Seeed Arch Max board)

EDIT – 2018.10.02
– added extended SPI DMA functions, see: viewtopic.php?f=15&t=3415

EDIT – 2018.09.12
– working CAN, see: http://stm32duino.com/viewtopic.php?f=3 … 239#p49235 (thanks to @michael_i!)

EDIT – 2018.03.19
– tested ADC, see: http://stm32duino.com/viewtopic.php?f=3 … 720#p42720

EDIT – 2018.02.18
– tested DAC, see: viewtopic.php?f=39&t=1976&p=41564#p41564

EDIT – 2018.01.16
– Added I2C (Wire), see: viewtopic.php?f=39&t=2804&p=37376#p37376

EDIT – 2017.07.10
– RTC lib reworked to be independent from other time libraries. Includes an example sketch to read and set the RTC time, as well as how to use the time elements.
It can be downloaded from here: viewtopic.php?f=39&t=775&p=31218#p31218

EDIT – 2017.06.18
– Implemented SDIO [non-HAL implementation] (for SD cards using latest SdFat lib made by Greiman)
viewtopic.php?f=39&t=2215

EDIT – 2017.06.02

Upload under windows currently only possible with STLink (V2).
When BOOT0=”1″(3.3V) and BOOT1=”0″(GND), the chip is recognized by Win10 as ‘STM Device in DFU mode’ (USB\VID_0483&PID_DF11).
However, there is no working DFU loader for Windows available, yet.

Comments & suggestions are welcome in this thread.
Any bug reports & PRs in Github, please.

————————————————————————————-
Hi all,

I know there is another thread on vet6 & zet6 boards, but there are at least 2 type of boards mixed, with partially different information.
And there is a lot of other information spread over other threads, like this generic implementation from danieleff.
Wiki has some basic stuff, too (thanks, Palmer!).

So, I got my black board today and I though it makes sense to open a separate thread only for the black VET6 board. The title can be edited later if needed, and the useful and tested information can (should) be added to wiki.

First of all, this is the current situation:
Both LEDs blink, but the USB device descriptor failed (VID 0x000 PID 0x0002).
On the serial port (115200Baud, 8N1) I receive after each reset: “LCD ID:ffff”
I can connect with the ST-Link probe, and I could read out the flash (I can attach here or to wiki if wanted). I assume writing would be also possible.

Now would like to start with the sw development.
The question is: how?

I know, there are a lot of alternative options (the official STM32 core, Start Otto github, Koduino, and so on).
But honestly, I like very much the existing Arduino_STM32 repo and I would like to use this for my future work.
I also know, it will be a hard way to go. But I think, with small steps I (we?) can achieve great results.

So, will the Arduino_STM32 provide the basic structure and functionality for a blinky example?
If anyone tried that already and had success, I would appreciate a short description of what and how to do.

For the beginning I intend to use the STlink upload method as the USB DFU seems not (yet?) to work.
Is there any working bootloader available for this board?

Replies20

stevestrong Tue Jan 16, 2018 3:28 pm

You can try the “Generic F407VE series” but as the name says, it is the VET version, not the ZGT, means different flash/ram size and board pinning.
But you could generate a new board variant, if you want.

michael_l Tue Jan 16, 2018 3:47 pm

I’d like to try this core with “Blue F407VET6” that has 25Mhz resonator. Steve, I wonder if you know what changes are needed for getting the 25Mhz resonator working ?

Image

Image

Manny Sun Jan 21, 2018 11:09 am

Downloaded your repo Steve and cant get serial USB to work or get recognised, using a STM32F407 mini.

Wolfie Wed Jan 24, 2018 9:54 am

Hi all,

Thanks for all the work you’ve done for this board. I’ve been using the STMF103CBT6 for some time now and was looking to “trade-up” to something with more ram, found this board on ebay… and now I’m here.

I noticed that there was a post for the W5500 being ported, so this morning I freshly downloaded Arduino_STM32 and Ethernet_STM32 and then tried this sketch:

#include <Ethernet_STM32.h>

SPIClass mSpi(1);

void setup() {
Serial.begin(115200);
delay(500);
Serial.print("initialising ethernet... ");
Ethernet.init(mSpi, PA4);
Serial.println("done");
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
Serial.print("initialising ethernet with DHCP... ");
if (Ethernet.begin(mac) == 0) {
Serial.println("failed");
} else {
Serial.println(" DHCP assigned IP ");
Serial.println(Ethernet.localIP());
}

}

stevestrong Wed Jan 24, 2018 10:21 am

Thanks for pointing to this issue, I just added that macro to /cores/maple/libmaple/gpio.h.
Please check it out again.

dannyf Wed Jan 24, 2018 2:18 pm



what changes are needed for getting the 25Mhz resonator working ?

Go through the code and search for HSE_Value. It can be changed in the code or via the ide preprocessor – st isn’t consistent on that.

You may also look through PLL settings to make sure that you don’t exceeded it’s max frequency.

Btw, did they really use a resonator and not a crystal? Shame on them if so.

Wolfie Wed Jan 24, 2018 3:07 pm

Thanks for pointing to this issue, I just added that macro to /cores/maple/libmaple/gpio.h.
Please check it out again.

Thanks for the fast response, I’ve just done a fresh download and it now compiles.

Of course it doesn’t do anything else, ha ha, but I’m new to the W5500, so I’ll make sure I’ve got everything set up correctly.

Regards.

stevestrong Wed Jan 24, 2018 3:23 pm

You could start with the WebClient example of my W5500 lib, using your own SPI instance.
Make sure that your router supports DHCP and allows new connections.
Also, be aware that not any MAC addresses are valid, so the router could refuse the connection based on that being invalid.

Wolfie Wed Jan 24, 2018 3:51 pm

You could start with the WebClient example of my W5500 lib, using your own SPI instance.
Make sure that your router supports DHCP and allows new connections.
Also, be aware that not any MAC addresses are valid, so the router could refuse the connection based on that being invalid.

Thanks Steve.

My main project last year involved Christmas lights panels on the windows. The panels of WS2812B leds were controlled by STM32F103(C8T6) modules and the PC sent the control information via WiFi to a ESP8266 which then passed on the data to the STM32F103 via serial. (9 panels of leds with 5 ESP8266->STM32F103 modules.)

This worked very well, but this year I want to do more, and the 20kB ram on the STM32F103 was getting to be a bit of a restriction.

So I wanted a board that had more ram, but was still easy to program, preferably by Arduino IDE. I have used STMCube + IAR but it it WAYYYY more complicated.

This black F407VET6 looks like a very promising replacement, and so this may also be a good time to consider removing the Wifi ESP8266 and connect the F407 directly to the LAN. Hence my interest.

I will look into your suggestion. As I am new to the W5500 I think I will maybe go back to the Uno, get this to work with the W5500, then progress to the F407VE, possibly via the F103…

Wolfie Thu Jan 25, 2018 11:02 am

Hello again,

Firstly, the W5500 module works fine with the Uno and Ethernet library, so I know the pin connections are correct and the module functions.

Secondly, I ran this to check the SPI pin allocations:

#include <SPI.h>
#include <Ethernet_STM32.h>

void setup()
{
Serial.begin(115200);
delay(500);

Serial.println("SPI default");
Serial.print("nss: "); Serial.print(SPI.nssPin()); Serial.print(" sck: "); Serial.print(SPI.sckPin()); Serial.print(" miso: "); Serial.print(SPI.misoPin()); Serial.print(" mosi: "); Serial.println(SPI.mosiPin());
Serial.print("nss: "); Serial.print(PA15); Serial.print(" sck: "); Serial.print(PB3); Serial.print(" miso: "); Serial.print(PB4); Serial.print(" mosi: "); Serial.println(PB5);
SPI.setModule(1);
Serial.println("SPI 1");
Serial.print("nss: "); Serial.print(SPI.nssPin()); Serial.print(" sck: "); Serial.print(SPI.sckPin()); Serial.print(" miso: "); Serial.print(SPI.misoPin()); Serial.print(" mosi: "); Serial.println(SPI.mosiPin());
Serial.print("nss: "); Serial.print(PA4); Serial.print(" sck: "); Serial.print(PA5); Serial.print(" miso: "); Serial.print(PA6); Serial.print(" mosi: "); Serial.println(PA7);
SPI.setModule(2);
Serial.println("SPI 2");
Serial.print("nss: "); Serial.print(SPI.nssPin()); Serial.print(" sck: "); Serial.print(SPI.sckPin()); Serial.print(" miso: "); Serial.print(SPI.misoPin()); Serial.print(" mosi: "); Serial.println(SPI.mosiPin());
Serial.print("nss: "); Serial.print(PB12); Serial.print(" sck: "); Serial.print(PB13); Serial.print(" miso: "); Serial.print(PB14); Serial.print(" mosi: "); Serial.println(PB15);
SPI.setModule(3);
Serial.println("SPI 3");
Serial.print("nss: "); Serial.print(SPI.nssPin()); Serial.print(" sck: "); Serial.print(SPI.sckPin()); Serial.print(" miso: "); Serial.print(SPI.misoPin()); Serial.print(" mosi: "); Serial.println(SPI.mosiPin());
Serial.print("nss: "); Serial.print(PA15); Serial.print(" sck: "); Serial.print(PB3); Serial.print(" miso: "); Serial.print(PB4); Serial.print(" mosi: "); Serial.println(PB5);

zmemw16 Thu Jan 25, 2018 11:20 am

PB4 on the schematic goes to the flash and the nrf24 socket, only!
you might have to play with remapping them.
stephen

stevestrong Thu Jan 25, 2018 12:42 pm

PB4 is marked on the schematic as PB4/TRST (JTAG header) and as SPI1_MISO (connected to FLASH and NRF24).
PB4 is SPI3_MISO, not SPI1_MISO. Hence, SPI1 should actually mean (be) SPI3. I think we had already a discussion about this at an earlier time.
SPI3 pins overlap with the SPI1 alternative configuration, but the default declared SPI instance is 3, inline with your pin test.

this fails immediately
What does it mean?
The sketch will hang when the connections are wrong.

I will check this again.

Wolfie Thu Jan 25, 2018 1:45 pm

Thanks guys, I have now found PB4 in the NRF interface, I will test for SPI3.

Wolfie Thu Jan 25, 2018 2:38 pm

Steve, maybe apologies.

I have tested the SPI3 with the same results, But I then checked everything again and I have realised that the chip on my ethernet module is a W5100 not a W5500. It was an unused one that I had in a drawer, I must have got confused about which it was.

Apologies if this makes a difference.

stevestrong Thu Jan 25, 2018 2:49 pm

No worries.
I was just thinking what else can be wrong in your case because everything works for me :)
But now it’s clear.
OTOH, my lib is restricted to W5500, no other variants are supported.

W5500 is more powerful than W5100, and has the same price, so it worth to have it.

Wolfie Thu Jan 25, 2018 3:39 pm

OTOH, my lib is restricted to W5500, no other variants are supported.

Good! We now know what the problem is!

I have just ordered 2 x W5500. If I only ordered 1 it would be faulty! :lol:

Sorry for wasting your time.

Wolfie Wed Feb 14, 2018 8:02 am

Hello again,

I’ve been doing a bit of PWM investigation. According to STM32CubeMX there are 32 PWM pins available, and with a bit of jiggery-pokery, I’ve got them all working.

Image

The above image shows the pin allocations for each timer.
The colouring shows the default frequency when using pwmWrite. Timers 1, 8, 9, 10 & 11 are attached to ABP2 which runs at 84MHz, and the others are attached to APB1 which runs at 42MHz, When using pwmWrite the count runs from zero to 65535 and so the frequency should be 84,000,000 / 65536 for timers on on APB1, and 42,000,000 / 65536 for timers on on APB2. The equate to 1282Hz and 641Hz respectively, which are remarkably close to the measured values (or a complete coincidence).

Image

The above image shows those pins that work without changing anything (I basically set a different frequency for each timer by setting the prescaler value and the ARR, and then set a different duty cycle for each channel, so every pwn pin had a unique signature).

(Note that PB4 is accessible via the “bottom right” pin of the NRF24L01 interface taking J-TAG as the “top” of the board.)

Firstly, I think there’s a bit of confusion over PA5 (timer 2 channel 1) as this appears in various places as PA15. If PA15 is indeed an alternative, I could not get it to work. However, after changing the details in Arduino_STM32\STM32F4\variants\generic_f407v\pin_map.c from PA15 to PA5 the pin sprang to life.

Similarly, the entries for PB10, PB11 and the pins for timers TIM10 – TIM14 were simply missing from pin_map.c, after adding in the timer and channel for each of these pins, they all started working too.

Of course, I don’t know whether adding in these entries will adversely affect anything else.

Regards…

stevestrong Wed Feb 14, 2018 5:00 pm

Can you do a PR?

PA15 is reserved for SPI3 NSS.
Timer 2 ch 1 is not mapped to PA5 to allow to be used as SPI1 SCK.
In the same context, PB10 and PB11 are reserved for (SPI2_SCK or I2C2_SCL or UASRT3_TX) and (I2C2_SDA or USART3_RX), respectively.

So Timer 2 was given lower prio versus I2C2/USART3, because there are plenty of other timers available on other pins.
Same applies for other pins you mentioned, in favor of SPI, I2C and USART.
Take a look into generic_f407v.h for reserved pins and what are they reserved for.

To activate TIMER2_CH1 on PA15, PA15 must be mapped to the respective alternate function AF1, which is not done in the current version of the repo.
You can use the function gpio_set_af_mode() using my repo.
gpio_set_af_mode(PA15, GPIO_AFMODE_TIM1_2);

Sign in to reply