Problem with Arduino R4 UNO

Hi,
I am trying to use simpleFOC on my UNO R4, I can input my code directly to the R4 but the motor won’t move and made some electiccal sound. Then I tried to add the PR from (Support Arduino UNO R4 Minima and WiFi - PWM by runger1101001 · Pull Request #289 · simplefoc/Arduino-FOC · GitHub) To the librery, i will receive a error massage in the Serial Monitor:

Firmware name: "C:\Users\User\AppData\Local\Temp\arduino\sketches\4DD59D3D067528632402041D653DDED4/q.ino", compiled on: Jul 27 2023

Fault on interrupt or bare metal(no OS) environment
  addr: 20007e90    data: 000117c9
  addr: 20007e94    data: 0000c97f
  addr: 20007e98    data: 20000358
  addr: 20007e9c    data: 20000f20
  addr: 20007ea0    data: 200002f8
  addr: 20007ea4    data: 20000f20
  addr: 20007ea8    data: 200005dc
  addr: 20007eac    data: 0000c9dd
  addr: 20007eb0    data: 200004cc
  addr: 20007eb4    data: 20000358
  addr: 20007eb8    data: 200002b8
  addr: 20007ebc    data: 00004243
  addr: 20007ec0    data: 00000000
  addr: 20007ec4    data: 00004040
  addr: 20007ec8    data: 0000a500
  addr: 20007ecc    data: ffffffff
  addr: 20007ed0    data: 20003064
  addr: 20007ed4    data: 0000cd91
  addr: 20007ed8    data: 000120a2
  addr: 20007edc    data: 40046f00
  addr: 20007ee0    data: 00000000
  addr: 20007ee4    data: 0000cdd3
  addr: 20007ee8    data: 000120a2
  addr: 20007eec    data: 000078f3
  addr: 20007ef0    data: 000120a2
  addr: 20007ef4    data: 0000ab4b
  addr: 20007ef8    data: 0000ab41
  addr: 20007efc    data: 00002599
====================================
=================== Registers information ====================
  R0 : 00000000  R1 : 00000000  R2 : 40078300  R3 : 00000000
  R12: e000e106  LR : 0000f76f  PC : 000000c0  PSR: 41000010
==============================================================
Usage fault is caused by attempts to execute an undefined instruction
Show more call stack info by run: addr2line -e "C:\Users\User\AppData\Local\Temp\arduino\sketches\4DD59D3D067528632402041D653DDED4/q.ino".elf -a -f 000000c0 0000f76e 0000c088 0000c088 0000c97e 0000c9dc 00004242 0000cd90 0000cdd2 000078f2 0000ab4a 0000ab40

Would this be my arduino software proplem?

Sorry for the terrible typesetting, didn’t notice it…

Hi @Test123 , and welcome to SimpleFOC!

Hmmm… is this on a UNO R4 Minima or R4 WiFi?

Are you sure the environment is set up correctly? Is this on ArduinoIDE or on PlatformIO?

The UNO R4 support is very new, so there could still be some bugs and problems. But this one looks more like something isn’t setup right - executing an undefined instruction isn’t something that should be caused by a bug in the simplefoc code, but more like a compiler error.

1 Like

Hi @runger, Thank you for your reply.
I am using R4 wifi with IDE.
I’m not sure what do you mean by environment set up but i’m using SimpleFOC Shieldv2.0.4, SimpleFOC library 2.3 with the R4 PR, the newest version of Arduino IDE and the code that works on Arduino Mega or R3.
However one of the code I use for testing encoder that has include SimpleFOC library in it works well and doesn’t have the error massage. Once I add any code related to motor or driver it will show the error massage again.
Have also tried run the code on other pc, got the same result…

Hey,

Have you applied just the UNO R4 PR to the master branch, or are you using the dev branch?

It would probably be good to use the dev branch…

I’m not at my computer this week but I will look into it as soon as I can

It is possibly the same as this issue:

It has a similar message in logs:

Fault on interrupt or bare metal(no OS) environment
===== Thread stack information =====
  addr: 20007e28    data: 00017915
  addr: 20007e2c    data: 0001772f

If it is then you may need to wait until 1.0.3 of renesas core is released (assuming the fix makes it into that release). You could also try an older version - perhaps this is a regression.

I still have the problem after update to ArduinoCore-renesas 1.0.4… I will have a try on dev branch today.

Hey @Test123,

For sure you have to use the dev branch for the moment if you want to use the UNO R4. The code for the Renesas MCU it is using is not yet in the release version of the library.

On the R4 Minima it is working for me.
On the R4 Wifi there is a problem, it crashes.

There seems to be a difference in how the R4 Wifi is using the framework that causes this error.

I’m looking into it.