Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

From pic to STM32

Veketti

Full Member level 3
Joined
Sep 14, 2014
Messages
164
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
1,700
Dear All,

Recently I designed portable device which uses PIC 16F1847 microcontroller and just bought out of curiosity STM32 discovery IoT kit with low power STM32L4S5 mcu and some STM32L4S5ZIT6 MCU's. My question is that with how big of a effort would that code be ported to the STM as I'm very curious to build the same with this MCU? I see that with STM cube one could easily get all the definitions ready so that it should be pretty much just start writing the code. And when I have the C language code written in mikroC pro for pic should it be pretty straight forward and almost copy paste thing? This has been in my mind to test the STM32 series for years but never really dare to bite the bullet. But now at least I have the hardware.

Of course in hardware wise I need to consider STM32 being 3.3V instead of 5V and rethink all the 5V peripherals..

Thank you in advance for your help/thoughts..
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
18,761
Helped
4,184
Reputation
8,370
Reaction score
4,120
Trophy points
113
Activity points
123,389
Hi,

moving from 5V to 3.3V is no big thing. I´d say it´s overdue ;-)

I´m no C specialist ... I can read it.

but porting code from one microcontroller family to another needs some tuning in the code.
For sure most of the math will be the same, bu you may need to adjust variable definitions, all the IOs and how they are accessed.
And (for me) most important is that when you move to a new family you should use the new features ... otherwise you lose the benefits of the new one.

We recently moved a project .. no ... we re-started the project. We began with AVR then moved to STM32F10x.
We tried to learn most of the STM32 features just within this one project. It was effort. A lot of effort - to be true.
But I´m impressed by the STM32.

There are differences in programming, one needs to accomodate with it. It takes time.

Please check whether STMCube output is caompatible with MicroC..

Klaus
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,872
Helped
14,125
Reputation
28,507
Reaction score
12,808
Trophy points
1,393
Location
Bochum, Germany
Activity points
277,837
It's more than copy and paste. The high level code can be just copied, but the low level code (hardware interface, timers, interrupts, serial drivers) has to be recreated for the new processor. Not a big thing for an embedded programming expert. STM cube framework can surely simplify the job.
 

Veketti

Full Member level 3
Joined
Sep 14, 2014
Messages
164
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
1,700
Hi,
So I bought STM32 discovery board L4S5I-IOT but I don't really need all the peripherals it has. However STM doesn't have plain board with just ST-Link and STM32L4S5 MCU. What are my options, as all the peripherals in this discovery board are useless to me? At least for now. I've found Mikroelectronica Fusion V8 board which is the closest, but it doesn't interact with STM32CubeIDE. Also it is pretty steep in price point for a hobby person.. For F0 and F1 series MCU there are plain boards but I want to use this ultra low power L4+ series.

Any recommendations for development boards?

Btw. this MCU seems amazing. It is so powerful and with freeRtos I can have separate task for ADC and separate for display update etc. Certainly overkill but I don't mind. And with CubeMX defining pins and initializing is really a step forward and so much more intuitive.
 

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,210
Helped
372
Reputation
744
Reaction score
367
Trophy points
83
Activity points
13,144
Don't forget that you are also moving from an 8-bit PIC MCU to a 32-bit ARM MCU that is about a decade further advanced in terms of when they were developed.
There are pro's and con's with this. You have mentioned that the STM MCU is faster and more capable, has more memory etc. but the IO (for example) is way more complex to set up - especially compared to the PIC. I am more than happy to program the PIC series of MCUs (except perhaps the PIC32 devices) directly, but I would not think of trying to write a of the code required for an ARM-based MCU without something like the STMCube.
If I were you, I would start with the discovery board you have and do things like getting a LED to flash at the correct rate and then perhaps respond to a push-button, talk to a PIC via the UART etc.. Start small and build up but use the peripherals that are on the board to start with. That way you will gain familiarity with the basic ways of programming the STM32 MCU.
Once you have that worked out, use the fact that the discovery board has a number of the IO pins brought out to the edge connectors and start interacting with your own peripherals.
Be prepared to take the concepts from the PIC world to the STM32 world but not much of the code. The low-level modules are just too different. The bit size difference can be handled to some extent by the C compiler but you need to be aware of the default variable sizes and how these affect the operation of your code.
Susan
 

Georgy.Moshkin

Full Member level 4
Joined
Oct 9, 2017
Messages
237
Helped
42
Reputation
84
Reaction score
33
Trophy points
28
Activity points
2,190
I would recommend the following setup:
1. USB2.0 hub with 4 ports (with wire)
2. USB-stick version of ST-LINK v2 programmer (2 pcs)
3. USB-stick version of TTL to USB adapter (2 pcs)
4. Bunch of colored wires with 2.54 connectors (3 types: male-male, male-female & female-female). Female to female cables of two lengths: short and long.
5. Digital oscilloscope, maybe even logic analyzer. At least a voltmeter.
6. Enough free space on the table.
7. Download datasheet, RM (reference manual), and PM (programming manual) for STM32 chip used on your board.
USB hub helps to organize the placement of components, put them farther away from computer's USB port.
It is very important to learn how to use Debug, some little useful options like Ctrl+Alt+B "Skip All Breakpoints" during debug in STM32CubeIDE, and activating breakpoints again by pressing Ctrl+Alt+B. If something goes wrong I usually use debug and serial output, check registers, step through HAL source codes and read RM (reference manual).
 

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top