dernasherbrezon / sx127x

Library to work with Semtech chips SX1276/SX1277/SX1278/SX1279.
Apache License 2.0
37 stars 7 forks source link

FIFO Problem #11

Closed Pascal66 closed 8 months ago

Pascal66 commented 8 months ago

My received frames are always truncated of the first byte. This is because you remove the first byte, considering it's only the packet_length stored on it in the case of VARIABLE.

In my implementation, my first byte contain not only the packet_lenght and other flags on it.

Pascal66 commented 8 months ago

//shortcut here for packets less than max fifo size Also this shortcut way is crazy I've to use the "slow" way.

dernasherbrezon commented 8 months ago

According to the specification length must be 1 byte:

Screenshot 2024-03-25 at 18 48 04
Pascal66 commented 8 months ago

In your read_payload_batch you can add device->packet[0] = value; ...And : device->packet[++device->fsk_ook_packet_sent_received] = value; // device->fsk_ook_packet_sent_received++;

This permit to return ALL the FIFO and not the FIFO less than the first byte.

dernasherbrezon commented 8 months ago

Yes, but this will make API inconsistent:

Pascal66 commented 8 months ago

Some need the entire FIFO, not truncated of the first byte. in your inconstitent API parts, it can be modified according this first byte. "More we have, more we can" Btw, I rewrited it for my need Thanks.

Pascal66 commented 8 months ago

FIFO problem is resolved, using a spi_device_interface_config_t dev_cfg = { .clock_speed_hz =4000000, ... Speed after 16MHz are wrong and need mode_1 and not mode_0 for both VSPI or HSPI with SPI_DMA_CH_AUTO

Same for Heltec or LilyGo

Rewrited the 3 modes: Normal, Burst, Fifo

dernasherbrezon commented 8 months ago

I also noticed when I used SPI speed ~8Mhz, data gets corrupted. I guess my ESP32 is not fast enough or crystal is not stable enough to generate good 8Mhz SPI signal. Some bit might flip when you send long sequence of "0" or "1". It can be solved by sending scrambled data.

Pascal66 commented 8 months ago

Both ESP32 (lilygo & heltec) are 240MHz. Not related. The SX1276 with SPI & DMA is at 10MHz and mode 0 You choose the right value with 3000000 (even it's better to use a multiple of 16)

dernasherbrezon commented 8 months ago

The SX1276 with SPI & DMA is at 10MHz and mode 0

Then maybe this is causing such issue. I don't have oscilloscope with ~16Mhz sampling rate to check that. Even if SX1276 rated at 10Mhz, it is not clear how they got this number. Maybe they used external TXCO with ~1ppm (connected to XTA pin). I think it depends on how the chip is connected to the rest of the board. Internal sx127x crystal is 20ppm.

Screenshot 2024-03-29 at 14 56 42