Skip to content

ADXL FIFO Example Watermark #2809

@JonasD27

Description

@JonasD27

Hi,
I have a question on the following section of the adxl38x fifo example under
https://github.com/analogdevicesinc/no-OS/blob/main/projects/eval-adxl38x/src/examples/fifo_example/fifo_example_main.c

while (true) {
		// Read status to assert if FIFO_WATERMARK bit set
		ret = adxl38x_read_device_data(adxl38x_desc, ADXL38X_STATUS0, 1, &status0);
		if (ret)
			goto error;
		pr_info("Status 0: %d\n", status0);
		ret = adxl38x_read_device_data(adxl38x_desc, ADXL38X_FIFO_STATUS0, 2,
					       fifo_status);
		if (ret)
			goto error;
		fifo_entries = no_os_get_unaligned_le16(fifo_status);
		fifo_entries = fifo_entries & 0x01ff;


		// Read FIFO status and data if FIFO_WATERMARK is set
		if (status0 & NO_OS_BIT(3)) {
			pr_info(" FIFO_WATERMARK is set. Total fifo entries =  %d\n", fifo_entries);
			if (fifo_entries < set_fifo_entries)
				goto unmatch_error;

This loop basically checks for the WATERMARK Bit in the status register. Why is there an unmatch error check after detecting the set WATERMARK Bit? By definition, the watermark bit should only be set when the desired amount of samples is reached in the fifo.
Why is this check needed?

In Addition:
In my implementation I noted, that after detecting the watermark bit as set, the number of fifo entries given by the FIFO_STATUS0 register is sometimes one sample behind.

For example:
Watermark threshold is set to 9 entries. After detecting that the watermark bit is set I immediately read the number of fifo entries from FIFO_STATUS0 register --> this yields only 6 samples.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions