Ethernet example for Fusion for STM32 v8

Fully featured ARM compilers available on Windows, Linux, and macOS.
Post Reply
Author
Message
sebastian.kraemer
Posts: 6
Joined: 01 Mar 2022 15:59

Ethernet example for Fusion for STM32 v8

#1 Post by sebastian.kraemer » 10 Mar 2022 15:55

Hi,
I'm having troubles getting the Ethernet_Demo running with the following setup:
  • development board: Fusion for STM32 v8
  • mcu card: STM32F407ZG
  • necto studio 1.8.6 with following setup selected:
    • Fusion for STM32 v8
    • mikroC AI for ARM
    • STM32F407ZG
    • CODEGRIP
    • 168MHz
    • No Display
According to the instructions on the beginning of the example file I:
  • Set all PORT B pins to pull down
  • Activated the button for Port B at SW3.3
  • Turned on Port D LEDS at SW4.8
Additionally, I adapted the ip address, gateway and dns ip address.

The example compiles without warnings, however, flushing resulted in no visible effect: The LEDs remain dark on the ethernet PHY and the selected IP is not pingable.

Using the Necto studio debugger shows that the function

Code: Select all

Ethernet_Intern_Init(...)
hangs for a few seconds and then returns with "1" which according to the documentation means some error occurred. Can you give me some guidance on how to further debug/fix this issue?

One thing that I'm not sure if it might somehow be related is the line "Oscillator: HSE-PLL, 150.000MHz" in the example description. I expect setting up the clocks correctly is done automatically by the mikroe sdk? Or do I have to adjust something manually?

User avatar
darko.ilijevski
Posts: 581
Joined: 21 Mar 2017 16:57

Re: Ethernet example for Fusion for STM32 v8

#2 Post by darko.ilijevski » 16 Mar 2022 11:26

Hello,

The problem is most likely in the selection of the clock settings. First of all, looking at your settings, I can see that the main CPU bus is 168 MHz, which indicated that you didn't use the correct settings. The external PHY for Ethernet is clocked by the MCO output so to get the required 50 MHz clocks, you need a different clock configuration. Below is the configuration we used in our example: it provides 150 MHz (from the 25MHz crystal oscillator) for the main bus and by using the MCO divider of 3, it provides 50 MHz for the PHY IC. You can check the MCU CARD schematics for more info on how the LAN8720A PHY is connected. You can also refer to LAN8720A datasheet for more details.

Regarding the configuration, you should get a new properly set HW config automatically when selecting the project example file (it will auto-generate HW configuration called "Fusion for STM32 v8 STM32F407ZG Ethernet". Also, this example is a legacy code, thus it doesn't rely on mikroSDK. As such, it is exclusive for the STM32F407. It could be easily ported to another architecture or MCU, but still - it wouldn't work out of the box.

Clock Settings for 50MHz at the MCO output
Clock Settings for 50MHz at the MCO output
Clock_407ZG_Ethernet.jpg (184.83 KiB) Viewed 2082 times
BR,
Darko

sebastian.kraemer
Posts: 6
Joined: 01 Mar 2022 15:59

Re: Ethernet example for Fusion for STM32 v8

#3 Post by sebastian.kraemer » 18 Mar 2022 08:13

Hi Darko,
I wasn't aware where to set the clock settings - my fault for not reading the documentation well enough. With the correct clock settings the ethernet example works so far (the LEDs are blinking and it's pingable).

Thanks for your help,
Sebastian

vmas
Posts: 6
Joined: 28 Nov 2022 15:08

Re: Ethernet example for Fusion for STM32 v8

#4 Post by vmas » 25 Feb 2023 09:33

The example Project named Ethernet_Demo (Ethernet Library demo for internal Ethernet module) cannot be compiled on NectoStudio, at 150Mhz and compiled at 72Mhz or 120Mhz does not work.
Is it possible to change the setup of the clock to make it work? ,so that MCO has 50 MHz for the PHY IC.

I would appreciate it if you could tell me the Ethernet_Demo on target Fusion for ARM v8 & MCU Card STM32407 link .

thanks and best regards.
Attachments
clock_necto_150.jpg
clock_necto_150.jpg (162.53 KiB) Viewed 1331 times
err_lib_delays.jpg
err_lib_delays.jpg (131.24 KiB) Viewed 1331 times

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: Ethernet example for Fusion for STM32 v8

#5 Post by IvanJeremic » 27 Feb 2023 14:16

Hi,

I have attached a scheme for this MCU for Ethernet usage:
STM32F407ZG_PLL_25_to_150MHZ_Ethernet.zip
(1020 Bytes) Downloaded 51 times
Hope it helps.

Regards,

Ivan.

vmas
Posts: 6
Joined: 28 Nov 2022 15:08

Re: Ethernet example for Fusion for STM32 v8

#6 Post by vmas » 27 Feb 2023 18:18

hi,
I have applied the configuration in two examples and it does not work.
Indicates an error in __lib_delays.c
however if I change the clock value of 150Mhz to 120 or 64 and the compilation is ok, but the example doesn't work.
Compiling at 120 Mhz , the debugger goes to assembler Ethernet_Demo.lst and I can't see the error..
Are these demo examples valid for Fusion Arm v8 and STM32F407 mcu?

Thanks
Attachments
err_lib_delays3.jpg
err_lib_delays3.jpg (95.64 KiB) Viewed 1284 times
err_lib_delays2.jpg
err_lib_delays2.jpg (110.26 KiB) Viewed 1284 times
STM32F407ZG_PLL_25_to_150MH.jpg
STM32F407ZG_PLL_25_to_150MH.jpg (191.52 KiB) Viewed 1284 times

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: Ethernet example for Fusion for STM32 v8

#7 Post by IvanJeremic » 19 Jan 2024 12:35

Hi,

I just opened the example and compiled and built it with no issues.

You can download my project below:
Ethernet Demo.7z
(1.77 MiB) Downloaded 28 times
Regards,

Ivan.

Post Reply

Return to “ARM AI Compilers”