0

I'm using the hardware PWM that is described on page 138 of the BCM2835-ARM-Peripherals document.

The description of the DMAC-register (page 145) indicates that one can set the FIFO-threshold at which the DREQ or PANIC-signal is sent to the Direct Memory Access hardware.

Bits 7:0 specify the DMA Threshold for the DREQ signal and bits 15:8 the DMA Threshold for the PANIC signal, so there are 8 bits for each threshold. The default value is 0x7, but there is no description on what this value actually means:

0x7 could indicate 7 free spaces or 7 filled spaces. The FIFO has a size of 8 32bit words, so it also could be the bitmask 0b0000 0111 and indicate either 3 free spaces or 3 filled spaces.

How to use this register so the signals are sent at the proper fifo thresholds?

For reference:

  1. This bcm2835-analog-audio driver kernel patch uses

    writel(0x80000E0E, chip->base + PWM_REG_DMAC);

    so it sets both thresholds to 0x0E.

  2. This Raspberry-Pi-DMA-Example sets both thresholds to 0x01 (PWM_FIFO_SIZE) with the comment:

    DREQ is activated at queue < PWM_FIFO_SIZE

  3. This "PiFM"-Implementation uses 0xF for both thresholds with the comment:

    I think this means it requests as soon as there is one free slot in the FIFO which is what we want as burst DMA would mess up our timing..

  4. This other "Raspberry PI FM Transmitter" just keeps the default 0x07 for both thresholds.

Has someone real knowledge about this or an idea for an experiment one could do to find out what it actually means?

1 Answer 1

0

I did setup a DMA-Chain with a PWM (running at 19.2Mhz/1920=10000Hz in serial mode) and tried different values for the thresholds and monitored the TXFR_LEN.

Result:

  • A threshold of 1 to 10 resulted in a lot of small writes into the Fifo
  • A threshold of 11 to 15 resulted in big writes.

So i assume that 1 is indeed the value for "Fill into Fifo as soon as there is a little bit of space" and 15 will wait until the Fifo is almost empty.

I couldn't determine any "in-between" values, though, but i now know, that i want to set the threshold for the PANIC-signal higher than the threshold for the normal DREQ-signal.

1
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year.
    – Ingo
    Feb 12, 2020 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.