RP2040 No low-side current support


We just made a motor controller with the DRV8323HRTAR and RP2040, and wanted to use SimpleFOC for current sensing on low-side. I noticed that SimpleFOC says it doesn’t support it though. Is there a reason for this?

Hi @Electrium_Mobility,

yes, the first was that, even though in theory there should be a DREQ to trigger DMA from the PWM, I could not get it to work. I am not sure if this is a silicon problem, a problem of my code, or the fact that the RP2040 Arduino core is on a fairly old SDK version. I could not get it to work, but I didn’t try with the earlehillpower core.

The DREQ is also at the wrong time in the PWM IIRC, and would involve inverting the PWM logic in some way to get the DREQ during the low-side on-time.

But the main reason is that it is unlikely to work well even if the chain of DMA requests were working. This is because the Pico’s ADC, in addition to its other faults, is very slow, and can only convert one channel at a time. So in response to a DMA trigger from PWM, it would have to convert at least 2 channels in succession, and this would not happen in time on low duty cycles, as the on-time of the PWM is too short.

Hmm, that makes sense.

In theory everything should be put together, but it seems that there are some intrinsic bugs on the RP2040 that doesn’t allow it to fully operate for the MCU.

We will try to see if we can get results with the earlehillpower core, and see if that makes any difference.


1 Like

Hai! @Electrium_Mobility

Could you try to run this loop on the RP2040, I’m curious to see how it performs without FPU?

long start_ticks = 0;
long stop_ticks = 0;
float elapsed_ticks = 0.0f;
float angle = 0.0f;
int count = 0;

start_ticks = micros();
for (angle = -pi; angle <= pi; angle += 0.001, count++) {

float angle2 = angle;
angle2 = _normalizeAngle(angle2);
float _ca = _cos(angle2);
float _sa = _sin(angle2);


stop_ticks = micros();

elapsed_ticks = stop_ticks-start_ticks;

Serial.print("Iterations: ");
Serial.print("elapsed_ticks: ");
Serial.println(elapsed_ticks, 4);
Serial.print("time per iterasion: ");
Serial.println(elapsed_ticks / count, 4);


1 Like