This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GPADAT bits remapping



Hi!

Is it possible to remap the bits in GPADAT so that I read only certain bits and in a different order than the 'normal' one?

I have an external ADC which outputs the data in parallel. The problem is that on the docking station, on one side I have the odd bits from GPADAT and some odd bits from GPBDAT, which are not even in increasing order. I'm reading now bit by bit and do the shiftings to get the 16bits result. But this is too slow, coz I have to read 12 ADC conversion results. Changing the hardware is not a solution, as the data lines length will increasing significantly, and the even GPIOs are used as PWMs anyway. Is there a possibility to define a structure exactly as I need it, and just read it. I've surfed through the files from controlsuite-> device_support, and I saw that GPIODAT is , as I understand, a 32-bit register that has associated a memory address. I don't have such deep knowlegde in C to make the changes to read just the bits I need. I don't even know if it's possible. I hope  somebody can help me on this.

Thank you,

Monica

  • Even if you were to remap the bits to  a structure, the compiler would just translate it to a series of bit shifts and bitwise operations to produce the result.

    If you can wire it as B1 = RESULT bit 0, A1 = RESULT bit 1, B3 = RESULT bit 2, A3 = RESULT bit 3...etc. then you should be able to do something like:

    Result = (GpioDataRegs.GPADAT.all & 0xAAAA) | ((GpioDataRegs.GPBDAT.all && 0xAAAA) >> 1)

    If that isn't fast enough/possible, I think you will need to rewire.