Skip to content

[New Variant] Nucleo 32 - STM32F042K6 #1099

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
4 of 8 tasks
battosai30 opened this issue Jun 15, 2020 · 11 comments · Fixed by #1491
Closed
4 of 8 tasks

[New Variant] Nucleo 32 - STM32F042K6 #1099

battosai30 opened this issue Jun 15, 2020 · 11 comments · Fixed by #1491
Labels
new variant Add support of new bard

Comments

@battosai30
Copy link

battosai30 commented Jun 15, 2020

Board description (please complete the following information):

Hi,
USB + CAN in this budget is pretty cool :)
Any plan on integration in this core ?
I'll buy one to try to add it myself but I'm not used with STM32 so ... :)

EDIT : integration started https://github.com/battosai30/Arduino_Core_STM32/tree/master/variants/NUCLEO_F042K6

  • All digital I/O working

  • All analog I/O working

  • All PWM I/O working

  • Serial (ST-LINK) working

  • Alternative Serial working

  • SPI working

  • i2c (master & slave) working

  • sleep working

@battosai30 battosai30 added the new variant Add support of new bard label Jun 15, 2020
@fpistm
Copy link
Member

fpistm commented Jun 16, 2020

Hi,
it has been added to the [New Variant] request list #722.

@fpistm fpistm closed this as completed Jun 16, 2020
@battosai30
Copy link
Author

Hi,
I worked on it and it seems basically okay. I succesfully ran a blink, serial communication between PC and board and I connected a RC522 so SPI works. Here the files before I start a PR.

I have some questions :

  • Is there any features list to test before starting a PR ?

  • in PeripheralPins.c I commented some lines about GPIOs needed for serial communication. But is there any good pratice about that ? Sorry I'm newby with STM32 :) I saw other variants with this kind of modifications, what could be the reasons ?

  • I had compilation error because in PinNamesVar.h some pins where not referenced. I look in the datasheet, this pins are not exposed by the LQFP32 package, is this a problem ?

  • Still in PinNamesVar.h I commented out PA_15 mentioned as USB_NOE. Is this a problem and what USB_NOE means ?

  • Is my clock config okay ?

image

Regards

@fpistm
Copy link
Member

fpistm commented Jul 16, 2020

Hi,
I worked on it and it seems basically okay. I succesfully ran a blink, serial communication between PC and board and I connected a RC522 so SPI works. Here the files before I start a PR.

Great. Thanks

I have some questions :

* Is there any features list to test before starting a PR ?

Basically, we test all basic Arduino API:
Serial, SPI, I2C, ADC, PWM

* in PeripheralPins.c I commented some lines about GPIOs needed for serial communication. But is there any good pratice about that ? Sorry I'm newby with STM32 :) I saw other variants with this kind of modifications, what could be the reasons ?

You can kept them. If user disabled the Serial usage then he could access them. In a general way, only the duplicated pins are commented as only the first one found is used. I will try to remove this limitation soo.

* I had compilation error because in PinNamesVar.h some pins where not referenced. I look in the datasheet, this pins are not exposed by the LQFP32 package, is this a problem ?

In that case simply comment them.

* Still in PinNamesVar.h I commented out PA_15 mentioned as USB_NOE. Is this a problem and what USB_NOE means ?

https://community.st.com/s/question/0D50X00009XkaCOSAZ/otg-on-l476-what-is-otgfsnoe
You can comment it without any issue.

* Is my clock config okay ?

image

It seems fine, anyway I will configure also USB clock at 48 MHz. To do this in CubeMX, enable the USB device support in the connectivity menu.

@battosai30
Copy link
Author

Thanks for your quick answer !

  • I had compilation error because in PinNamesVar.h some pins where not referenced. I look in the datasheet, this pins are not exposed by the LQFP32 package, is this a problem ?
    In that case simply comment them.

I can't, I specially added them because if I don't, I get the same error as here #907

It seems fine, anyway I will configure also USB clock at 48 MHz. To do this in CubeMX, enable the USB device support in the connectivity menu.

And here comes a little problem : USB and CAN cannot be used at the same time because they share the same pins. As I understand it, CAN doesn't need a clock configuration, so I should active USB and disable CAN in CubeMX so at least USB is ready to use and CAN (I guess) too. Can you confirm that ?

Regards

@fpistm
Copy link
Member

fpistm commented Jul 16, 2020

OK for the pinname var.
and yes for USB and CAN. I'm only talking about USB clock.

@battosai30
Copy link
Author

Just to be sure, you confirm that if I want to use CAN, that won't be an issue if I don't activate it in CubeMX ?

CAN is the "cool" thing for me in this MCU, so after integration in Arduino itself I will try to get CAN working ;)

@fpistm
Copy link
Member

fpistm commented Jul 16, 2020

Yes this is not dependent.
FYI it seems someone already do a CAN library for this core:
https://github.com/exothink/eXoCAN

Tested only for F103 but I guess it could be a good base for you.

@battosai30
Copy link
Author

Thanks !
I found this too :
https://github.com/nopnop2002/Arduino-STM32-CAN
https://github.com/seeers/CAN-Bus-Arduino_Core_STM32

@battosai30
Copy link
Author

A simple blink code takes 9196 bytes of memory. I tried disabling HAL components :

#define HAL_ADC_MODULE_DISABLED
#define HAL_I2C_MODULE_DISABLED
#define HAL_RTC_MODULE_DISABLED
#define HAL_SPI_MODULE_DISABLED
#define HAL_TIM_MODULE_DISABLED

Is this normal ?

@fpistm
Copy link
Member

fpistm commented Jul 17, 2020

by default yes it seems normal. By disabling all HAL module should reduce it.
Where did you define it ? You have to use the build-opt.h for this

@battosai30
Copy link
Author

Oh ok I read two quickly the wiki ;)

I had a hal_conf_extra.h file to my sketch and compiled with :

#define HAL_ADC_MODULE_DISABLED #define HAL_I2C_MODULE_DISABLED #define HAL_RTC_MODULE_DISABLED #define HAL_SPI_MODULE_DISABLED

And I got a 9092kB flash size :s Disabling Serial gives 7736kB . Better

I tried with HAL_*_MODULE_DISABLED but got the same size (9196kB) with warnings like :

warning: ISO C++11 requires whitespace after the macro name 9 | #define HAL_*_MODULE_DISABLED | ^~~~

So I guess this directive was not taken account ... And the * is responsible of this (Arduino v1.8.10) as when I erase it warnings disapear.

fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Sep 9, 2021
Fixes stm32duino#1099

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new variant Add support of new bard
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants