using only portions of arduino-land with CubeMX HAL

Development of new Cores using the STMCubeMX and HAL
ms34me
Posts: 3
Joined: Thu Dec 10, 2015 5:27 pm

using only portions of arduino-land with CubeMX HAL

Postby ms34me » Fri Dec 11, 2015 6:24 am

Hello:

I recently got this PCB that has a temp, humidity, and CO2 sensor on it with RS-232. However, it has a STM32F030C8T6 on it. As I understand it, none of the stuff ported over will work with this chip. Maybe I have that wrong?

Anyways, I looked over the CubeMX HAL examples, and it looks pretty straight forward, as far as doing the little things I need to do like setting digital ports, reading analog pins, and I2C.. but I am really missing the Serial.print functions, and how easy that made my life. I am very accustomed to using these functions to print data and manipulate the UART.

So my question is this: is there any way just to get read(), write(), available(), and print() functions working with this chip, using CubeMX and Keil? Or should I just bite the bullet and learn the lower level stuff?

Thank You

User avatar
sheepdoll
Posts: 216
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex
Contact:

Re: using only portions of arduino-land with CubeMX HAL

Postby sheepdoll » Fri Dec 11, 2015 7:47 am

Serial.print() should work with the CubeMX Hal that I did last spring. read() and available() need more testing work.
The port setup baud rate, stop bits etc. is done through the Cube tool. Serial.begin() was needed to allocate the print stream, As I recall, the setting themselves are ignored. I think the F0 example I included set one of the serial ports to 9 bit processor mode. This can be checked from within the Cube tool.


Hopefully after the first of the year I will have some time to work at this again.

ms34me
Posts: 3
Joined: Thu Dec 10, 2015 5:27 pm

Re: using only portions of arduino-land with CubeMX HAL

Postby ms34me » Fri Dec 11, 2015 8:16 am

sheepdoll wrote:Serial.print() should work with the CubeMX Hal that I did last spring. read() and available() need more testing work.
The port setup baud rate, stop bits etc. is done through the Cube tool. Serial.begin() was needed to allocate the print stream, As I recall, the setting themselves are ignored. I think the F0 example I included set one of the serial ports to 9 bit processor mode. This can be checked from within the Cube tool.


Well, I'm here and can start testing this, is there any way I can test your work without having to use the other functionality of arduino-land such as I2C? read() and available () are pretty important to me, because the command parser I wrote forever ago uses them and I don't understand how to convert them to work with CubeMX HAL.

I am really trying to learn this stuff better, I want to force myself to learn this stuff, and not rely on arduino so much. However, i think their UART functions make a lot of sense and do everything i'd ever need them to do.

What do you suggest the best way to get started?

ms34me
Posts: 3
Joined: Thu Dec 10, 2015 5:27 pm

Re: using only portions of arduino-land with CubeMX HAL

Postby ms34me » Fri Dec 11, 2015 9:41 am

sheepdoll wrote:I think the F0 example I included set one of the serial ports to 9 bit processor mode.


i might be an idiot, but I do not see an F0 example =\

edit, i found it but still have no idea what i'm doing

User avatar
sheepdoll
Posts: 216
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex
Contact:

Re: using only portions of arduino-land with CubeMX HAL

Postby sheepdoll » Mon Dec 14, 2015 11:25 pm

ms34me wrote:
sheepdoll wrote:I think the F0 example I included set one of the serial ports to 9 bit processor mode.


i might be an idiot, but I do not see an F0 example =\

edit, i found it but still have no idea what i'm doing


I have been rather busy this last week.
You need both
https://github.com/sheepdoll/HALMX_Arduino_STM32/tree/master/HALMX/variants/MXDiscoF051R8
and
https://github.com/sheepdoll/HALMX_Arduino_STM32/tree/master/examples
I think these are still the same as https://github.com/rogerclarkmelbourne/HALMX_Arduino_STM32

Basically there is one set of examples. The heavy lifting is done through the variants folder. Inside the variants folder is a *.ioc file. This is what opens with the CubeMX tool. The F0 discovery one is on the main site as https://github.com/rogerclarkmelbourne/HALMX_Arduino_STM32/blob/master/HALMX/variants/MXDiscoF051R8/MXDiscoF051R8.ioc I noticed in Git that this is just a text file with the configuration. That is where the peripherals are set. This does break the "Arduino" model of configuring thinks like baud rates in the setup() section. It is however necessary when using serial stream to instantiate the class through something like Serial.begin(9600) Currently though as I recall the baud rate is ignored.

The real interesting effects are the HAL_Direct examples. The HAL headers are included in Main, so the sketch can directly see the calls. I was finding this a really good way to explore HAL.

My work flow was to run CubeMX and configure the hardware. Note that the *.ioc is saved inside the version control, as are the files CubeMx writes such as main.c and things like gpio.c. In practice only main.c is touched to include the calls to setup() and loop(). I do not let the Arduino IDE run till after I have configured the peripherals.

Once configured I do run the IDE. As noted above the HAL callbacks are exposed so one can do simple sketches that call them.

I use Mac OSX, so the configurations for downloading to the STLink are designed for that environment. As I need some features that were later deprecated, I still use 10.7.5 on my main computer. Otherwise I am using Yosemite. Have not yet upgraded to El Capitan.


Return to “CubeMX and HAL”

Who is online

Users browsing this forum: No registered users and 1 guest