u/sudheerpaaniyur

I’m stuck on the sort012 code.

Hi, I’m not sure why mid++ is incrementing here. My understanding is that it might not correctly store the value 1 at that index.

if(a[mid] ==0)//0
{
tmp=a[mid];
a[mid]=a[start];
a[start]=tmp;
start++;
mid++;

}

//int a[]={2,0,1,0};
void sort012(int *a, int n)
{
    int start=0;
    int mid=0;
    int end=n-1;
while(mid < end)
{
    int tmp;
    if(a[mid] ==0)//0
    {
        tmp=a[mid];
        a[mid]=a[start];
        a[start]=tmp;
        start++;
        mid++;


    }else if(a[mid]==1)//1
    {
        mid++;


    }
    else //2
    {
        tmp=a[mid];
        a[mid]=a[end];
        a[end]=tmp;
        end--;
    }
}
reddit.com
u/sudheerpaaniyur — 2 days ago
▲ 7 r/FPGA

RISC-V or ARM which one have future ?

I’m a senior embedded dev working on bare-metal drivers (SPI, ADC, I2C) with solid ARM architecture experience. Planning to move into RISC-V on the FPGA side. I have some basic VHDL/Verilog from college and am looking for a solid course that covers RISC-V core implementation on FPGA. Also wondering if this is a good career move coming from embedded systems. Recommendations welcome.

reddit.com
u/sudheerpaaniyur — 2 days ago

PID position controller, actuator not hitting full stroke

>I'm building a closed-loop position controller for a linear actuator on an STM32F3. The actuator amplifier takes ±10V. DAC midpoint 2048 = 0V (zero force), 0 = −10V, 4095 = +10V.

>When I command a full sine cycle the actuator should travel the full stroke from −10V to +10V, but it's not happening. It moves but doesn't reach either end.

>Video and full code here: https://github.com/servoxctrl/pid

u/sudheerpaaniyur — 3 days ago