Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5022

General • Re: N phase shifted pwm signals

$
0
0
Just do this on the CPU using DMA and PIO.

Talking through the look up table (lut). You have 4 pins, each pin has its own bit sequence table within a 8-bit parallel write. There are 10 steps per period. I can process two steps in parallel. Which have four possible bit sequences.

Code:

    typedef uint16_t custom_t[5]; // We do two step in parallel using SIMD bit operation on int.        uint16_t lut[4][1 << 2]; // Two bits in two bits out.        template <typename T> inline void PWM<T>::build_period(custom_t *result, uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3) {        if (result != nullptr) {        for (uint8_t nib = 0; nib < 10; nib += 2) {                SIMD::SIMD_QUARTER<T> *c[4] = { get_table(v0 % (1 << 10), 0, nib), get_table(v1 % (1 << 10), 1, nib), get_table(v2 % (1 << 10),  2, nib), get_table(v3 % (1 << 10), 3, nib) };                    for (uint32_t i = 0; i < 5; i++) {                    // Superscalar Operation (forgive the loads)                    SIMD::SIMD_QUARTER<T> p = *c[0] | *c[1] | *c[2] | *c[3];                                (*result)[i] = p.v;                    // Superscalar operation                    for (uint32_t j = 0; j < 4; j++)                        ++c[j];                }            }        }    }        template class PWM<uint16_t>;

Statistics: Posted by dthacher — Wed Nov 06, 2024 9:43 am



Viewing all articles
Browse latest Browse all 5022

Trending Articles