Post Go back to editing

Fail to Pass Overwrite Waveform Data From no-OS to Windows OS

Category: Hardware
Product Number: AD-PQMON-SL

Hardware: AD-PQMON-SL

 

Goal:

Pass the Epoch timestamp from no-OS to Windows OS

 

Expected Result on Windows OS:

waveform[0]: -16634

waveform[1]: 5558

waveform[2]: 417

waveform[3]: 0

 

Error Result on Windows OS:

waveform[0]: -8

waveform[1]: -13

waveform[2]: -3

waveform[3]: -5

 

Error Video:

 

 

Troubleshooting step that has taken:

Asked GitHub Copilot where to insert my code in no-OS, same file and same line.

 

Code Snippet on no-OS:

no-OS/projects/eval-pqmon/src/common/pqlib_afe.c at dev/pqmon-zephyr-ptp · analogdevicesinc/no-OS

		status = afe_read_waveform(
			(uint16_t *)&(pqlibExample.inputWaveform.waveform),
			ADI_PQLIB_WAVEFORM_BLOCK_SIZE
			* ADI_PQLIB_TOTAL_WAVEFORM_CHANNELS);
		// ----------------------------------------------------------------------------------------------------- //
		// Testing
		ADI_PQLIB_TIME waveform_start_epoch_time;
		waveform_start_epoch_time = 1791365660422;
		
		// Split the timestamp and store in the first 4 positions of the waveform array,
		pqlibExample.inputWaveform.waveform[0] = (int16_t)(waveform_start_epoch_time & 0xFFFF);
		pqlibExample.inputWaveform.waveform[1] = (int16_t)((waveform_start_epoch_time >> 16) & 0xFFFF);
		pqlibExample.inputWaveform.waveform[2] = (int16_t)((waveform_start_epoch_time >> 32) & 0xFFFF);
		pqlibExample.inputWaveform.waveform[3] = (int16_t)((waveform_start_epoch_time >> 48) & 0xFFFF);

		// Result
		printf("waveform[0]: %"PRId16"\n", pqlibExample.inputWaveform.waveform[0]);
		printf("waveform[1]: %"PRId16"\n", pqlibExample.inputWaveform.waveform[1]);
		printf("waveform[2]: %"PRId16"\n", pqlibExample.inputWaveform.waveform[2]);
		printf("waveform[3]: %"PRId16"\n", pqlibExample.inputWaveform.waveform[3]);

		// ----------------------------------------------------------------------------------------------------- //
		pWaveform->isDataProcessed = 0;
		pWaveform->sequenceNumber++;

Full Code on Windows OS:

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "include/iio.h"

int main() {

	// Step 1: Create a context from the serial port   
    struct iio_context* ctx = iio_create_context_from_uri("serial:COM4,115200,8n1");
    const struct iio_device* dev = iio_context_get_device(ctx, 0);

    // Step 2 Set process_data = 0
    iio_device_attr_write_double(dev, "process_data", 0);
    
    // Step 3 Enable all channels 
    for (unsigned int chn_index = 0; chn_index < iio_device_get_channels_count(dev); chn_index++) {
        struct iio_channel* chn_enabled = iio_device_get_channel(dev, chn_index);
        if (iio_channel_is_output(chn_enabled) == 0) {
            iio_channel_enable(chn_enabled);
        }
    }

	// Step 4 Set waveform_capture_mode = continuous
    iio_device_attr_write(dev, "waveform_capture_mode", "continuous");
    
	// Step 5 Create a buffer to read data from the device
    struct iio_buffer* buffer = iio_device_create_buffer(dev, 256, false);

    iio_buffer_refill(buffer);

    int16_t* waveform = (int16_t*)iio_buffer_start(buffer);

	// Step 6 Result
    printf("waveform[0]: %"PRId16"\n", waveform[0]);
    printf("waveform[1]: %"PRId16"\n", waveform[1]);
    printf("waveform[2]: %"PRId16"\n", waveform[2]);
    printf("waveform[3]: %"PRId16"\n", waveform[3]);


    // Step 7 Clean up
    iio_buffer_destroy(buffer);
    iio_context_destroy(ctx);
    
}

Edit Notes

Update data type of
[edited by: YongLawrence at 12:22 AM (GMT -4) on 9 Oct 2026]

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.