User Tools

Site Tools


en-us_commands:reference:fifo

This is an old revision of the document!


FIFO()

FIFO() outputs the first stored 16-bit data first.

FIFO command operation flow

bool FIFO(uint8_t fifo_id, bool IN, bool OUT, uint16_t input, uint16_t &output, uint8_t size, bool reset = false)

Commands

Command Arguments Return Value Operation
FIFO(fifo_id, IN, OUT, input, output, size, reset) uint8_t fifo_id — Buffer ID
bool IN — Store input on the rising edge
bool OUT — Output on the rising edge
uint16_t input — Word to store
uint16_t &output — Reference variable receiving the output
uint8_t size — Buffer size
bool reset = false — Reset the buffer
bool Outputs the first stored 16-bit data first.

Example

uint16_t fifoValue = 0;
uint16_t filoValue = 0;
uint16_t sequence = 0;
 
void setup() {
  Serial.begin(115200);
}
 
void loop() {
  const bool store = Iup(0, IdigitalRead(0, 5));  // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state. / Return true only at the instant the input changes from OFF to ON.
  const bool release = Iup(1, IdigitalRead(1, 5));  // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state. / Return true only at the instant the input changes from OFF to ON.
  const bool reset = IdigitalRead(2, 5);  // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state.
 
  if (store) ++sequence;
  const bool fifoOk = FIFO(0, store, release, sequence, fifoValue, 16, reset);  // Output the first stored 16-bit data first.
  const bool filoOk = FILO(0, store, release, sequence, filoValue, 16, reset);  // Output the last stored 16-bit data first.
  if (release && fifoOk && filoOk) {
    Serial.print(F("oldest=")); Serial.print(fifoValue);
    Serial.print(F(", newest=")); Serial.println(filoValue);
  }
}

Precautions

IN, OUT, CU and CD act on rising edges. Use a unique id for each counter or buffer, and keep size to the required minimum.

Built-in Commands in the Same Category

en-us_commands/reference/fifo.1788796396.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki