Author Topic: WIll te same code work  (Read 1668 times)

0 Members and 1 Guest are viewing this topic.

Offline AndreilieTopic starter

  • Newbie
  • Posts: 1
  • Country: ro
WIll te same code work
« on: March 02, 2019, 02:42:41 pm »
Hello,

I have a silly question I think.
Iwant to use for a project an existing code written for stm32f405 microcontroller, which has an ARM Cortex-M4F core.
Can I use the code for a STMF7 CHIP ?

Thanks.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: WIll te same code work
« Reply #1 on: March 02, 2019, 03:43:11 pm »
Your question is answered in AN4660.
 

Offline Fred27

  • Supporter
  • ****
  • Posts: 737
  • Country: gb
    • Fred's blog
Re: WIll te same code work
« Reply #2 on: March 02, 2019, 06:31:04 pm »
I find that code ports easily, but peripheral setup takes some tweaking. It should be reasonably simple if you're sticking with STM32s, but will still take some time and effort.
 
The following users thanked this post: TomS_

Offline TomS_

  • Frequent Contributor
  • **
  • Posts: 861
  • Country: gb
Re: WIll te same code work
« Reply #3 on: March 04, 2019, 01:57:42 pm »
I find that code ports easily, but peripheral setup takes some tweaking. It should be reasonably simple if you're sticking with STM32s, but will still take some time and effort.

This would match my experience too.

The main logic of your application should be portable enough between platforms and families - but the bits that interface with peripherals (configuring timers/responding to their interrupts, talking to UARTs etc) will need to be adapted on a per device/family basis.

If your code is well written, the peripheral interfaces should be abstracted away from your application logic code so that they can be replaced easily. If not, this would be a good exercise to do just that. The build environment should ideally make some variables available to the compiler so that you can use ifdefs etc to include or exclude different pieces of code depending on the type of device the code is being compiled for.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->