Skip to content

[New Variant]STM32F401 #594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mrguen opened this issue Aug 10, 2019 · 59 comments · Fixed by #604
Closed

[New Variant]STM32F401 #594

mrguen opened this issue Aug 10, 2019 · 59 comments · Fixed by #604
Labels
enhancement New feature or request new variant Add support of new bard question ❓ Usually converted as a discussion

Comments

@mrguen
Copy link
Contributor

mrguen commented Aug 10, 2019

Helllo, Thanks for the huge quantity of work!

I would like to know if you plan to include in the release 1.7.0 these generic variants for F401

STM32F401CC in UFQFPN48 and LQFP64 packages

STM32F401RCT6 in LQFP64 package

Generally speaking how do you handle the different packages versions?

@mrguen mrguen added the new variant Add support of new bard label Aug 10, 2019
@pkourany
Copy link
Contributor

@mrguen, I have the RCT6 variant working on my system with v1.61 but haven't create a PR yet. I you want the variant file package and changes boards.txt file, I can post it.

@mrguen
Copy link
Contributor Author

mrguen commented Aug 12, 2019

@pkourany Oh, Thanks a lot. That would be nice of you.

@pkourany

This comment has been minimized.

@mrguen
Copy link
Contributor Author

mrguen commented Aug 14, 2019

Ok, Thanks Paul. The issue was open for STM32F401... I don't know if these files might help for the RCT6 type...

@pkourany
Copy link
Contributor

pkourany commented Aug 14, 2019

Oh boy. I must have dyslexia cause I read F103RCT6 somehow! I'm going to hide that post since it isn't relevant.

BTW, a lot of the work is done by STM32CubeMX by creating a project for the MCU/package you want, configuring the clock for internal/external crystals and creating the code for that variant you want. From this, you can get the code to copy to the ldscript.ld file and the clock configuration code (from main.c) to place in the variant.c file. The PeripheralPins.c and PinNamesVar.h files for all variants can be obtained here. The variant.c and variant.h files can be adapted to a simple list of pin names.

variant.h
#define PA0   0
#define PA1   1
... for all GPIO pins on package

varian.c
const PinName digitalPin[] = {
  PA_0,  //D0
  PA_1,  //D1
  PA_2,  //D2
... for GPIO pins in package

You will also need to review other #defines in variant.h to match the pin counts, # of analog pins, LED pin, etc.

The last thing is to add the variant to the boards.txt file so it appears in the menu.

@mrguen
Copy link
Contributor Author

mrguen commented Aug 14, 2019

Ok. I tried to do it by following your method and https://github.com/stm32duino/wiki/wiki/Add-a-new-variant-(board)

A) **************
There was a compilation problem because the board is not considered in Arduino15\packages\STM32\hardware\stm32\1.6.1\system\Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h

So I added

#if defined(STM32F401xC)
#include "stm32f401xc.h"

and uncommented #define STM32F401xC

B) **************
I modified boards.txt as :

################################################################################

Generic F4

GenF4.name=Generic STM32F4 series

GenF4.build.vid=0x0483
GenF4.build.core=arduino
GenF4.build.board=GenF4
GenF4.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} {build.bootloader_flags}
GenF4.build.mcu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
GenF4.build.series=STM32F4xx
GenF4.build.cmsis_lib_gcc=arm_cortexM4l_math

Secret Garden F401RC

GenF4.menu.pnum.STM32F401RCT6=Secret Garden F401RCT6
GenF4.menu.pnum.STM32F401RCT6.upload.maximum_size=262144
GenF4.menu.pnum.STM32F401RCT6.upload.maximum_data_size=65536
//GenF4.menu.pnum.STM32F401RCT6.build.board=STM32F401RCT6
GenF4.menu.pnum.STM32F401RCT6.build.product_line=STM32F401xx
GenF4.menu.pnum.STM32F401RCT6.build.variant=STM32F401RCT6

C) **************
But now there is a compilation error:

WARNING: Category 'Language' in library ArduinoStreaming is not valid. Setting to 'Uncategorized'
Un sous-r�pertoire ou un fichier sketch existe d�j�.

In file included from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\system/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:30,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\system/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:29,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\system/STM32F4xx/stm32f4xx_hal_conf_default.h:291,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\system/STM32F4xx/stm32f4xx_hal_conf.h:13,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\system/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h:30,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\system/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:252,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/stm32/stm32_def.h:35,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/stm32/clock.h:43,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/wiring_time.h:23,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/wiring.h:38,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/Arduino.h:32,
from sketch\Blink.ino.cpp:1:
#ifndef __STM32F4xx_H

In file included from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/stm32/stm32_def.h:35,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/stm32/clock.h:43,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/wiring_time.h:23,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/wiring.h:38,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/Arduino.h:32,
from sketch\Blink.ino.cpp:1:
#ifndef __STM32F4xx_H

In file included from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\system/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rtc.h:29,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/stm32/LL/stm32yyxx_ll_rtc.h:21,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/stm32/backup.h:26,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/board.h:9,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/wiring.h:41,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/Arduino.h:32,
from sketch\Blink.ino.cpp:1:
#ifndef __STM32F4xx_H

In file included from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\system/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h:29,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/stm32/LL/stm32yyxx_ll_gpio.h:21,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/stm32/digital_io.h:43,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/board.h:12,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/wiring.h:41,
from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino/Arduino.h:32,
from sketch\Blink.ino.cpp:1:
#ifndef __STM32F4xx_H

exit status 1
processing.app.debug.RunnerException
at cc.arduino.Compiler.lambda$callArduinoBuilder$3(Compiler.java:309)
at processing.app.debug.MessageSiphon.run(MessageSiphon.java:96)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at cc.arduino.Compiler.message(Compiler.java:525)
at cc.arduino.i18n.I18NAwareMessageConsumer.message(I18NAwareMessageConsumer.java:80)
at cc.arduino.MessageConsumerOutputStream.flush(MessageConsumerOutputStream.java:71)
at cc.arduino.MessageConsumerOutputStream.write(MessageConsumerOutputStream.java:54)
at java.io.OutputStream.write(OutputStream.java:75)
at cc.arduino.Compiler.lambda$callArduinoBuilder$3(Compiler.java:307)
... 2 more

@pkourany
Copy link
Contributor

@mrguen can you zip your variant directory and share here?

@mrguen
Copy link
Contributor Author

mrguen commented Aug 14, 2019

Here it is: STM32F401RCT6.zip

boards.txt

@mrguen
Copy link
Contributor Author

mrguen commented Aug 14, 2019

Here is what I have done :

  1. Copy C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\variants\board_template
    to
    C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\variants\STM32F401RCT6

  2. In STM32CubeMX
    Used the default settings for STM32F401RC but changed

  • the clock for HSE / Crystal/Ceramic, set 8 MHz crystal M=4 PLL= 168 P=4 Q=7
    SYSCLK = 84 MHZ AHBPrescaler = 1 APB1Prescaler = 2

· Activated USART1 Asynchronous
· Activated SPI1 / Full Duplex master
· Activated USB / OTG/Dual role device
Generated the code for SW4STM32

  1. Copied STM32F401RCTx_FLASH.ld to ldscript.ld

  2. Copied SystemClock_Config(void) from the generated main.c to variant.cpp

  3. Copied the files PeripheralPins.c and PinNamesVar.h from https://github.com/stm32duino/Arduino_Tools/tree/master/src/genpinmap/Arduino/STM32F401R(B-C)Tx to the STM32F401RCT6 folder

  4. Copied digitalPin array in variant.cpp and pin defines in variant.h from NUCLEO_F401RE

In fact I am using this board https://fr.aliexpress.com/item/32894670982.html?spm=a2g0s.9042311.0.0.27426c37RrpWiJ and really don’t know their pin mapping. I have asked them a documentation… I suppose I can manage with the Nucleo numbering. I only changed the BOOT1 that was not considered on the NUCLEO board.

  1. Modified boards.txt by adding in the “# Generic F4” section

Secret Garden F401RC

GenF4.menu.pnum.STM32F401RCT6=Secret Garden F401RCT6
GenF4.menu.pnum.STM32F401RCT6.upload.maximum_size=262144
GenF4.menu.pnum.STM32F401RCT6.upload.maximum_data_size=65536
//GenF4.menu.pnum.STM32F401RCT6.build.board=STM32F401RCT6
GenF4.menu.pnum.STM32F401RCT6.build.product_line=STM32F401xx
GenF4.menu.pnum.STM32F401RCT6.build.variant=STM32F401RCT6

  1. There was a compilation error. I had to add at line 144 in C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\system\Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h

#if defined(STM32F401xC)
#include "stm32f401xc.h"

And uncomment #define STM32F401xC

@mrguen
Copy link
Contributor Author

mrguen commented Aug 15, 2019

The seller sent me the link to the documentation : https://wetransfer.com/downloads/493b7605d31718be87a56133e7cc70d920190814152406/f44f44?spm=a2g0s.imconversation.0.0.7d7a3e5fzulqrL

There is a lot of material. Including an STM32CubeMX project that I used to replace ldscript.ld and · SystemClock_Config()

The compile error is still the same.

@fpistm
Copy link
Member

fpistm commented Aug 15, 2019

Do not modify the core file.
Your issue comes from your board definition:

GenF4.menu.pnum.STM32F401RCT6.build.product_line=STM32F401xC

@mrguen
Copy link
Contributor Author

mrguen commented Aug 15, 2019

I modified the boards.txt as explained but the error is still raised.
error compiling for STM32F401RCT6 .txt

@fpistm
Copy link
Member

fpistm commented Aug 15, 2019

It seems you have an preprocessor directive issue, missing #endif or something like that.
I could not help this week I'm on vacation. I will test next week,

@mrguen
Copy link
Contributor Author

mrguen commented Aug 15, 2019

Ok, Thanks, I let a #if instead of changing to #elif in stm32f4xx.h

Now, despite the #define STM32F401xC in stm32f4xx.h

it seems to be unknown by stm32_def_build.h

In file included from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino\stm32\startup_stm32yyxx.S:1:
C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino\stm32\stm32_def_build.h:336:2: error: #error UNKNOWN CHIP
#error UNKNOWN CHIP

stm32f4xx.zip

@fpistm
Copy link
Member

fpistm commented Aug 19, 2019

Hi @mrguen

I would like to know if you plan to include in the release 1.7.0 these generic variants for F401

STM32F401CC in UFQFPN48 and LQFP64 packages

STM32F401RCT6 in LQFP64 package

There is no plan for this. This is a community project and all contributions are welcome.

Generally speaking how do you handle the different packages versions?

In fact, variant is mainly how you order the pin (pin mapping) and linked to a board. Then the board determines the package used.
Anyway a fully generic variant dedicated only to a MCU could be done and then a dedicated entry in the boards.txt could be used to determine the package.

@mrguen
Copy link
Contributor Author

mrguen commented Aug 19, 2019

@fpistm Ok, so if you can help me debug I will provide these...

@fpistm
Copy link
Member

fpistm commented Aug 19, 2019

About your build issue, as I mentioned you don't have to modify the core files.
The include is already present and the define have to be done thanks the boards.txt.

Using your variant and updating properly the boards.txt there is no build issue.
I will provide a branch on my fork with some update.

@fpistm fpistm added question ❓ Usually converted as a discussion Request labels Aug 19, 2019
@mrguen
Copy link
Contributor Author

mrguen commented Aug 19, 2019

  1. It's written in the file line 72: "/* Uncomment the line below according to the target STM32 device used in your
    application
    */"

  2. (after restoring the original file) At compilation it raises the error
    "C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\system/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:191:3: error: #error "Please select first the target STM32F4xx device used in your application (in stm32f4xx.h file)"
    #error "Please select first the target STM32F4xx device used in your application (in stm32f4xx.h file)"
    "

  3. After uncommenting the line 91 " #define STM32F401xC "

It still raises en error:

In file included from C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino\stm32\startup_stm32yyxx.S:1:
C:\Users\TG\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\cores\arduino\stm32\stm32_def_build.h:336:2: error: #error UNKNOWN CHIP
#error UNKNOWN CHIP
^~~~~
exit status 1
Error compiling for board Generic STM32F4 series.

@fpistm
Copy link
Member

fpistm commented Aug 19, 2019

Well, it's also written this:

/* Tip: To avoid modifying this file each time you need to switch between these
devices, you can define the device in your toolchain compiler preprocessor.
*/

Please, come back to original core files and only update your variant and boards.txt as described in the wiki.

fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Aug 19, 2019
Fixes stm32duino#594

Co-authored-by: Thierry GUENNOU <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
@fpistm
Copy link
Member

fpistm commented Aug 19, 2019

@mrguen ,
here a proposed variant for your board:
fpistm@a83cf0c

fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Aug 19, 2019
Fixes stm32duino#594

Co-authored-by: Thierry GUENNOU <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
@mrguen
Copy link
Contributor Author

mrguen commented Aug 20, 2019

@fpistm,

Thanks. I could compile blink.

@fpistm
Copy link
Member

fpistm commented Aug 20, 2019

@mrguen
Note that, I will not be able to test as I don't have this board.

@mrguen
Copy link
Contributor Author

mrguen commented Aug 20, 2019

@fpistm: do you have a test protocol?

@fpistm
Copy link
Member

fpistm commented Aug 20, 2019

Well, I have to deploy a test bench but don't have time yet to do it with a tests lists. 😭
Usually, I use standard Arduino sketch to test each feature and some of our sketches examples of our libraries.

@fpistm
Copy link
Member

fpistm commented Aug 21, 2019

Well, I think you have a driver issue. "STM device in DFU mode" should be "STM32 BOOTLOADER"
so probably you installed another driver for DFU.

@fpistm
Copy link
Member

fpistm commented Aug 21, 2019

You can try the driver provided with the tool:
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\Drivers\DFU_Driver

@mrguen
Copy link
Contributor Author

mrguen commented Aug 21, 2019

Yes, it is working now.
It does switch from DFU to USB/CDC after downloading.
It is very fast. I could set Serial @ 2 MHz (really?)

@fpistm
Copy link
Member

fpistm commented Aug 21, 2019

Fine.
After upload the STM32CubeProgrammer start your binary.
For USB, the speed is not relevant.

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

Hello @fpistm !

I am reviewing PeripheralPins.c and I can see that

Some timers functions are defined on two pins but other that could use 2 pins are defined on one pin only. Some timer signals are missing a pin (BKIN, ETR) etc...

Should the timers definition section list all pins/functions possible as referenced in "STM32F401xB STM32F401xC" datasheet?

@fpistm
Copy link
Member

fpistm commented Aug 22, 2019

The file is generated automatically and provides only used signal. BKIN and ETR are ignored when extracted. If they are required later they could be added.
Here all the generated file and script to generate them using CubeMx xml files.
https://github.com/stm32duino/Arduino_Tools/tree/master/src/genpinmap

As you can see here only TIMx_CH are kept:
https://github.com/stm32duino/Arduino_Tools/blob/5d77a614f11665443f8485733ddd781fb04f8ed0/src/genpinmap/genpinmap_arduino.py#L202

if "_CH" in signal:

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

  1. There are also CHxN pins defined...

  2. What about arbitrating between pins/functions?

For example TIM2_CH1 is defined for PA0 and PA5 while PA0 could be used for TIM5_CH1 which is not mapped.

Can I change it / is there any other impact?

  1. Some USART alt pins are not defined (PD5, PD6, PA11, PA12) while USART1 alt pins are.

  2. Generally speaking does a pin has to be defined for only one function or for all possible functions ?
    Example
    PA_7 is mapped to
    ADC7, TIM1_CH1N, SPI_MOSI

@fpistm
Copy link
Member

fpistm commented Aug 22, 2019

1. There are also CHxN pins defined...

Yes as you can see the CHxN are also included as the test check if _CH is contained in the signal name...

2. What about arbitrating between pins/functions?

For example TIM2_CH1 is defined for PA0 and PA5 while PA0 could be used for TIM5_CH1 which is not mapped.

Can I change it / is there any other impact?

Do what you want, the array is also WEAK so you can override it at sketch level to fit your needs and save memory space.

3. Some USART alt pins are not defined (PD5, PD6, PA11, PA12) while USART1 alt pins are.

PA11/12 are for USB so I comment it. PD5/6 does not exist.

4. Generally speaking does a pin has to be defined for only one function or for all possible functions ?
    Example
    PA_7 is mapped to
    ADC7, TIM1_CH1N, SPI_MOSI

If a pin is not connected to dedicated hardware then we could provide all possible functions.
If you want use it as SPI then you can or as an ADC...

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

Also I just realize that the files you provided are not those from https://github.com/stm32duino/Arduino_Tools/tree/master/src/genpinmap/Arduino/STM32F401R(B-C)Tx

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

Here is the proposed PeripheralPins.c
PeripheralPins.zip

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

I see two differences in the ldcript provided as compared to Altium's:

  1. possibly missing
    No _Min_Heap_Size = 0x400;      /* required amount of heap  */ that was in the original Altium project

  2. Added properties . = ALIGN(4); in many places

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

The proposed PeripheralPins.c discards TIM9, TIM10 and TIM11 but I see in variant.cpp
#define TIMER_TONE TIM10
#define TIMER_SERVO TIM11

So it might be necessary to reactivate
TIM10_CH1 instead of TIM4_CH3
TIM11_CH1 instead of TIM4_CH3
?

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

Here is the updated PeripheralPins.c + excel sheet detailing the code review
PeripheralPins.zip

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

About BOOT configuration:
To upload using STM32Prog, BOOT0= 1 but in this case pushing reset does not reset the program and BOOT0 must be set to 0 to manually reset.

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

So far I have tested:

Passed:
Blink: ok
AnalogReadSerial: A0 and A15 : ok
DigitalReadSerial : all 46 pins Ok but PA11 and PA12 that are DM and DP thus canno't have serial

Not ok:
IWDG_button: WDT does not seem to reset
eeprom_wite (value = 100) then eeprom_read: all values are '255'

@fpistm
Copy link
Member

fpistm commented Aug 22, 2019

I see two differences in the ldcript provided as compared to Altium's:

1. possibly missing
   No _Min_Heap_Size = 0x400;      /* required amount of heap  */ that was in the original Altium project

2. Added properties . =   ALIGN(4); in many places

This is correct.
37f6252#diff-fddda161300d628fd4ca3bfe7a9fa835R58

The proposed PeripheralPins.c discards TIM9, TIM10 and TIM11 but I see in variant.cpp
#define TIMER_TONE TIM10
#define TIMER_SERVO TIM11

So it might be necessary to reactivate
TIM10_CH1 instead of TIM4_CH3
TIM11_CH1 instead of TIM4_CH3
?

No, there is no link between Tone or Servo and the Pinmap PWM array which is used for analogWrite... Tone or Servo use the hardware timer resources and are not link to a pin....

To upload using STM32Prog, BOOT0= 1 but in this case pushing reset does not reset the program and BOOT0 must be set to 0 to manually reset.

Right this is normal... to start the program you have to come back to default Boot pattern else you start in Bootloader mode...

Passed:
Blink: ok
AnalogReadSerial: A0 and A15 : ok
DigitalReadSerial : all 46 pins Ok but PA11 and PA12 that are DM and DP thus canno't have serial

Not ok:
IWDG_button: WDT does not seem to reset
eeprom_wite (value = 100) then eeprom_read: all values are '255'

For IWDG and eeprom I've tested a F401RE without any issue.
About IWDG ensure to have boot0 set to 0. For eeprom, I can not help.

@fpistm
Copy link
Member

fpistm commented Aug 22, 2019

Your update of PeripheralPins.c is not correct and I don't understand why you do this.
Anyway I will kept the variant as it is. Basic features worked including USB.
Thanks for the test.

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

PeripheralPins.c is the file from https://github.com/stm32duino/Arduino_Tools/tree/master/src/genpinmap/Arduino/STM32F401R(B-C)Tx

It seems the other lacked some pin/timer mapping (maybe I am wrong of course I don't know this as you do)

With pin arbitration between Timers defined as in the excel file in the .zip.

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

I will do some other things tomorrow and come back to this afterward if you'd like.

@fpistm
Copy link
Member

fpistm commented Aug 22, 2019

This is the same files except the commented lines...

@mrguen
Copy link
Contributor Author

mrguen commented Aug 22, 2019

Yes possibly but I find it nice to have all possible mappings written. I have checked all are correct / datasheet and chose to promote TIM2 and TIM5 instead of TIM9/10/11 because they are 32 bits and that is what I am looking for with this IC !

@fpistm
Copy link
Member

fpistm commented Aug 23, 2019

Well as said the PWM array is for analogWrite() to generate the PWM so we don't bother if 16 or 32 bits.
Moreover with the Hardware Timer library, we use all timer as 16 bits for genericity purpose:
https://github.com/stm32duino/wiki/wiki/HardwareTimer-library#1-introduction
But nothing prevents you from using a timer in 32 bits using LL or HAL directly!

@mrguen
Copy link
Contributor Author

mrguen commented Aug 23, 2019

Thanks for the info... I am very much surprised. I will have a look at the library. Usually it is also possible to access the registers so I don't see why it wouldn't be 32 bits.

@fpistm
Copy link
Member

fpistm commented Aug 23, 2019

For the provided API 16 bits is enough. For further use case HAL/LL could be used.

fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Aug 27, 2019
Fixes stm32duino#594

Co-authored-by: Thierry GUENNOU <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Aug 28, 2019
Fixes stm32duino#594

Co-authored-by: Thierry GUENNOU <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
fpistm added a commit that referenced this issue Aug 28, 2019
Fixes #594

Co-authored-by: Thierry GUENNOU <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
@fpistm fpistm added enhancement New feature or request and removed Request labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new variant Add support of new bard question ❓ Usually converted as a discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants