PiMagic777
Posts: 15
Joined: Mon Jun 05, 2017 12:48 pm

PCM/I2S Audio CS Register: RXTHR, TXTHR

Sat Sep 09, 2017 11:52 am

BCM2835 ARM Peripherals Data Sheet p.128 describes the RXTHR and TXTHR fields. (Copied below).
For both RXTHR and TXTHR the description for bit settings 01 and 10 is confusing to me. Especially RXTHR. Has anyone figured out what is meant here?
RXTHR 00 is clear: RXR flag is set when RX FIFO has one sample
RXTHR 11 is clear: RXR flag is set when RX FIFO is full
BUT descriptions for RXTHR 01 and 10 seem ambiguous/incomplete. Anyone have experience with this?

-------------------------------------------------------- From the Data Sheet ---------------------------------------------------------------------
8:7 RXTHR Sets the RX FIFO threshold at which point the RXR flag is set RW 0x0
00 = set when we have a single sample in the RX FIFO
01 = set when the RX FIFO is at least full
10 = set when the RX FIFO is at least
11 = set when the RX FIFO is full

6:5 TXTHR Sets the TX FIFO threshold at which point the TXW flag is set RW 0x0
00 = set when the TX FIFO is empty
01 = set when the TX FIFO is less than full
10 = set when the TX FIFO is less than full
11 = set when the TX FIFO is full but for one sample

LdB
Posts: 568
Joined: Wed Dec 07, 2016 2:29 pm

Re: PCM/I2S Audio CS Register: RXTHR, TXTHR

Mon Sep 11, 2017 7:50 am

No experience with it but it's pretty obvious it's setting the FIFO levels for the compare register and interrupt if enabled. I agree the wording is a bit strange but I am guessing the original data sheet had wording which explained "least full" etc had some value something like 1/4 FIFO depth.

You should be able to work it out reasonable easily on the transmit just set the mode and then make a tight loop like so

clear count
loop:
Tx a byte
Inc count
Check if TXW flag set
if not set goto loop
count has how roughly many bytes in fifo before TXW set

Essentially you are working on the fact the loop is so tight it will be faster than the sample can be cleared. So you should very quickly fill the TX fifo triggering the TXW flag at some count value.

PiMagic777
Posts: 15
Joined: Mon Jun 05, 2017 12:48 pm

Re: PCM/I2S Audio CS Register: RXTHR, TXTHR

Mon Sep 11, 2017 7:03 pm

Yes agree thanks. Probably something like 1/4 full and 3/4 full or some such. I am most interested in the values for the Rx FIFO, but I think I can figure them out by experiment. I have already tested a lot by connecting PCM out to PCM in and writing known patterns out on PCM out and reading them back on PCM in. Just have to be careful with the timing and see what thresholds in Rx FIFO cause RXR flag to get set

LdB
Posts: 568
Joined: Wed Dec 07, 2016 2:29 pm

Re: PCM/I2S Audio CS Register: RXTHR, TXTHR

Tue Sep 12, 2017 1:26 am

Given your setup it's pretty easy to get the RX count. As slow as possible send bytes from the sender board.

On the receive board setup a FIFO level, then just spin reading the trigger flag.
The moment it sets jump over to the RX fifo and empty it counting how many bytes you have.

If you have the TX board slow enough emptying the FIFO should occur before another byte arrives and you have the exact count.

Return to “Bare metal”

Who is online

Users browsing this forum: No registered users and 3 guests