-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to change size between header blocks in sweep mode? #1485
Comments
The fixed sizes involved here are related to our available space for sample buffering. In order to simultaneously capture samples from the ADC and send buffered samples over USB to the host, we need the MCU's USB peripheral to be able to read from one part of the sample buffer via DMA, whilst the M0 core writes samples into another part of the buffer, both with very tight timing requirements. The only way we can reliably achieve that is to have the buffer straddle a boundary between two different SRAM blocks, such that each half has its own connection to the AHB bus matrix. Otherwise we get intermittent delays due to bus contention, which can cause us to miss deadlines and lose samples. The only part of the LPC4320's memory map which satisfies this property is 32KB in size, with two 16KB halves. So everything happens in 16KB blocks. In RX mode, the M0 writes samples continuously, wrapping around the 32KB buffer. Whenever it fills one 16KB block, we tell the USB peripheral to grab that block over DMA and send it to the host. As long as the host keeps polling us for data fast enough, that transfer will complete before the M0 wraps back to the same half of the buffer again. Sweep mode works a little differently, but is still oriented around 16KB blocks. We capture and transfer as many blocks as requested per frequency step, and then pause for two 16KB block periods while we retune the RF path. However, currently even if you request multiple blocks, every block gets a header written to it, so even though the samples captured at each frequency are contiguous across the blocks captured, you don't get a continuous waveform. If that's the part that's causing you issues, it would be possible to modify the code to take some extra options during sweep setup, so that when it captures multiple blocks per frequency step, it only writes a header to the first block. |
Thanks for a quick reply! |
I removed part of code that created headers in usb_api_sweep.c:
After that, I set receiver like this: Than I tried to record sine wave that tuned to 1300MHz and get this result: Recorded signal is devided by blocks. Each of the block is 0.4096ms long. Which is correlate with size of block with header. I expected this type of behavior after 131072 samples. There we can see edges in sine each 6.5536ms. Which is exaclty 131072 samples. I send my program which I used to record. Maybe problem is in the way I use receiver. It is on C# with connected hackrf.dll. All function names are the same.
|
I'm not sure quite what we can do for you at this point. It sounds like you may be developing a new feature. I suggest opening a pull request if that is the case. |
I decided not to use sweep mode but change frequency manually in default mode. And I added an option to the original library that allows me to change USB transfer size (which is fixed to 262144 by default, as I remember). So I have something similar to sweep mode now, but with a contiguous waveform. This approach is almost as fast as sweep mode, except for the low USB transfer size (<32768, I think). Do I understand it right? Sweep mode was originally developed to calculate the power level of each sweep step. In this case, a contiguous waveform would not be necessary. |
What would you like to know?
As I understood, right now sweep mode returns data in blocks of 16 384 bytes including header. Function
hackrf_init_sweep
has parameternum_bytes
but it only defines count of blocks with headers. If I tellnum_bytes
to be 32 768, I'll get two blocks with headers with the same frequency in it. As I see in source code, the code to change tuning frequency calles regardless tonum_bytes
value. Size of blocks hardcoded in firmware. This behavior leads to a problem with timing data from this two blocks.I searched firmware and libhackrf projects for all hardcoded values that related to the size between headers and doubled it.
List of changes I did in firmware:
Searched all 0x4000 and 0x8000 values, and defined them as 0x8000 or double.
List of changes i did in libhackrf:
But after this change M0 stucks in RX.
do I understand something wrong, or did I missed code with hardcoded value of 16 384, or maybe there is some hardware limitations in HackRF?
The text was updated successfully, but these errors were encountered: