Esempio n. 1
0
        public static void testGetGPIOMonitor()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte spiData1 = 0x0;
            byte spiData2 = 0x0;
            byte monitorIndex;
            int  monitorMask;
            byte retmonitorIndex = 0;
            byte retmonitorMask  = 0;

            Link.Mykonos.setupGpio(0x00FF, Mykonos.GPIO_MODE.GPIO_MONITOR_MODE, Mykonos.GPIO_MODE.GPIO_MONITOR_MODE, Mykonos.GPIO_MODE.GPIO_MONITOR_MODE, Mykonos.GPIO_MODE.GPIO_MONITOR_MODE, Mykonos.GPIO_MODE.GPIO_MONITOR_MODE);

            for (monitorIndex = 0; monitorIndex <= 0x35; monitorIndex++)
            {
                //Console.WriteLine("monitorIndex: " + monitorIndex);
                for (monitorMask = 0; monitorMask <= 0xFF; monitorMask++)
                {
                    Console.WriteLine("monitorIndex: " + monitorIndex);
                    Console.WriteLine("monitorMask: " + monitorMask);
                    Link.spiWrite(0xB40, monitorIndex);
                    Link.spiWrite(0xB41, (byte)monitorMask);


                    Link.Mykonos.getGpioMonitorOut(ref retmonitorIndex, ref retmonitorMask);

                    Assert.AreEqual(monitorIndex, retmonitorIndex, "Monitor Index not as expected");

                    Assert.AreEqual(monitorMask, retmonitorMask, "Monitor Mask not as expected");
                }
                //monitorIndex++;
            }
            Link.Disconnect();
        }
Esempio n. 2
0
        public static void EnableTxNCO()
        {
            /* not working yet */
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            string firPath   = @"C:\svn\software\projects\mykonos\Filters\"; //TODO: replace with dynamic
            string txFirFile = firPath + "TxApp49_307p2_BW250_PriSigBW100.ftr";

            //Link.Mykonos.programFir(Mykonos.FIR.TX1TX2_FIR, txFirFile);

            //Link.Mykonos.setEnsmPinMode(0);
            //Link.Mykonos.setEnsmState(Mykonos.ENSM_STATE.TX_RX);
            //Link.Mykonos.powerUpTxPath(Mykonos.TXCHANNEL.TX1_TX2);
            //Move to Radio On ARM state
            Link.Mykonos.radioOn();

            byte spiReg = Link.spiRead(0x1B0); Console.WriteLine("SPI Reg x1B0 = " + spiReg.ToString("X"));

            spiReg = Link.spiRead(0x1B3); Console.WriteLine("SPI Reg x1B3 = " + spiReg.ToString("X"));


            Link.spiWrite(0xC40, 0x80); //enable Tx NCO
            Link.spiWrite(0x9CB, 0x5);  //freq
            Link.spiWrite(0x9CC, 0x5);  //freq
            Link.spiWrite(0x9CD, 0x5);  //freq
            Link.spiWrite(0x9CE, 0x5);  //freq

            Link.Disconnect();
        }
Esempio n. 3
0
        public static void testsetGpio3v3SourceCtrl()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte   spiData1    = 0x0;
            byte   spiData2    = 0x0;
            UInt16 gpio3v3Oe   = 0x0;
            UInt16 readGpioSrc = 0;

            foreach (Mykonos.GPIO3V3_MODE gpio3v3Mode3_0 in Enum.GetValues(typeof(Mykonos.GPIO3V3_MODE)))
            {
                foreach (Mykonos.GPIO3V3_MODE gpio3v3Mode7_4 in Enum.GetValues(typeof(Mykonos.GPIO3V3_MODE)))
                {
                    foreach (Mykonos.GPIO3V3_MODE gpio3v3Mode11_8 in Enum.GetValues(typeof(Mykonos.GPIO3V3_MODE)))
                    {
                        Link.Mykonos.setGpio3v3SourceCtrl((UInt16)(((byte)gpio3v3Mode3_0 & 0x0F) | (((byte)gpio3v3Mode7_4 & 0x0F) << 4) | (((byte)gpio3v3Mode11_8 & 0x0F) << 8)));

                        Link.spiWrite(0xB06, (byte)(((byte)gpio3v3Mode3_0 & 0x0F) | (((byte)gpio3v3Mode7_4 & 0x0F) << 4)));
                        Link.spiWrite(0xB07, (byte)((byte)gpio3v3Mode11_8 & 0x0F));

                        spiData1 = Link.spiRead(0xB06); Console.WriteLine("0xB06: " + spiData1.ToString("X"));
                        Assert.AreEqual(gpio3v3Mode3_0, (Mykonos.GPIO3V3_MODE)(spiData1 & 0x0F), "lower byte lower nibble readback not as expexted");

                        spiData1 = Link.spiRead(0xB06); Console.WriteLine("0xB06: " + spiData1.ToString("X"));
                        Assert.AreEqual(gpio3v3Mode7_4, (Mykonos.GPIO3V3_MODE)((spiData1 & 0xF0) >> 4), "lower  byte upper nibble  readback not as expexted");

                        spiData1 = Link.spiRead(0xB07); Console.WriteLine("0xB07: " + spiData1.ToString("X"));
                        Assert.AreEqual(gpio3v3Mode11_8, (Mykonos.GPIO3V3_MODE)(spiData1 & 0x00F), "upper byte lower nibble readback not as expexted");
                    }
                }
            }
            Link.Disconnect();
        }
Esempio n. 4
0
        public static void CheckTxFirFilter([Values(Mykonos.FIR.TX1_FIR, Mykonos.FIR.TX2_FIR)] Mykonos.FIR txFirMode)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte   spiData1  = 0x0;
            byte   firMSB    = 0;
            byte   firLSB    = 0;
            string txFirFile = settings.resourcePath + @"\DigitalFilters\" + "TxApp47_245p76_BW200_PriSigBW75.ftr";

            Link.Mykonos.programFir(txFirMode, txFirFile);

            //Select PFIR to RX1
            if (txFirMode == Mykonos.FIR.TX1_FIR)
            {
                spiData1 = Link.spiRead(0xDFF);
                Link.spiWrite(0xDFF, (byte)(spiData1 & 0xF1));
            }
            else if (txFirMode == Mykonos.FIR.TX2_FIR)
            {
                spiData1 = Link.spiRead(0xDFF);
                Link.spiWrite(0xDFF, (byte)(spiData1 & 0xF2));
            }
            else
            {
                throw new ArgumentException();
            }


            //Readback Filter data

            //Read Configured TX Gain
            //Read Read Number of Taps
            //Cross reference Coeffecients
            spiData1 = Link.spiRead(0x910); Console.WriteLine("Myk:Tx Filter Gain: " + (spiData1 & 0x03).ToString("X"));
            Assert.AreEqual(0x1, ((spiData1 & 0x01)), "Myk: Tx Filter Gain: not as expected");
            spiData1 = Link.spiRead(0x10); Console.WriteLine("Myk: Tx Filter NumOf Taps: " + (spiData1).ToString("X"));
            Assert.AreEqual(0x00, ((spiData1 & 0xE0) >> 5), "Myk: Tx Filter NumOf Taps not as expected");


            Int16[] coefs = new Int16[16];
            for (int i = 0; i < 16; i++)
            {
                Link.spiWrite(0xE01, (byte)(i * 2));
                firLSB = Link.spiRead(0xE00);
                Link.spiWrite(0xE01, (byte)(i * 2 + 1));
                firMSB = Link.spiRead(0xE00);

                coefs[i] = (Int16)(((UInt16)(firMSB) << 8) | (UInt16)(firLSB));
                Console.WriteLine("Coef[" + i + "]: " + coefs[i]);
                Assert.AreEqual(TxFirCoeffs[i], coefs[i], "Myk: Tx FilterCoeff" + i.ToString("d") + "not as expected");
            }
            Link.Disconnect();
        }
Esempio n. 5
0
        public static void EnableRxFramerPrbs([Values(Mykonos.MYK_PRBS_ORDER.PRBS7, Mykonos.MYK_PRBS_ORDER.PRBS15, Mykonos.MYK_PRBS_ORDER.PRBS31)] Mykonos.MYK_PRBS_ORDER prbsorder)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            //reset the device
            Link.Mykonos.resetDevice();
            System.Threading.Thread.Sleep(100);

            //setting SPI channel for 4-wire mode
            Link.setSpiChannel(1);
            Link.spiWrite(0x000, 0x18);

            Link.Mykonos.enableRxFramerPrbs(prbsorder, 1);
            byte PRBSspi = Link.spiRead(0x72);

            if (prbsorder == Mykonos.MYK_PRBS_ORDER.PRBS7)
            {
                Assert.AreEqual(PRBSspi, 0x01, "PRBS7 mismatch");
            }
            else if (prbsorder == Mykonos.MYK_PRBS_ORDER.PRBS15)
            {
                Assert.AreEqual(PRBSspi, 0x03, "PRBS15 mismatch");
            }
            else
            {
                Assert.AreEqual(PRBSspi, 0x05, "PRBS31 mismatch");
            }

            Link.Disconnect();
        }
        public static void EnableDeframerPrbsChecker([Values(Mykonos.MYK_PRBS_ORDER.PRBS7, Mykonos.MYK_PRBS_ORDER.PRBS15, Mykonos.MYK_PRBS_ORDER.PRBS31)] Mykonos.MYK_PRBS_ORDER prbsorder)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            //setting SPI channel for 4-wire mode
            Link.setSpiChannel(1);
            Link.spiWrite(0x000, 0x18);

            Link.Mykonos.enableDeframerPrbsChecker(0xF, prbsorder, 1);
            byte PRBSspi = Link.spiRead(0xA5);

            if (prbsorder == Mykonos.MYK_PRBS_ORDER.PRBS7)
            {
                Assert.AreEqual(PRBSspi, 0xF1, "PRBS7 mismatch");
            }
            else if (prbsorder == Mykonos.MYK_PRBS_ORDER.PRBS15)
            {
                Assert.AreEqual(PRBSspi, 0xF3, "PRBS15 mismatch");
            }
            else
            {
                Assert.AreEqual(PRBSspi, 0xF5, "PRBS31 mismatch");
            }


            Link.Disconnect();
        }
Esempio n. 7
0
        public static void ReadRxGainTable()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            byte spiReg1     = 0;
            byte spiReg2     = 0;
            byte index       = 0;
            byte feGain      = 0;
            byte extControl  = 0;
            byte digGain     = 0;
            byte enableAtten = 0;

            Link.setSpiChannel(1);

            Link.spiWrite(0x00A, 0x84);
            spiReg1 = Link.spiRead(0x00A); Console.WriteLine("Scratch Reg Test: " + spiReg1.ToString("X"));
            Assert.AreEqual(0x84, spiReg1, "SPI not working");

            Link.spiWrite(0x516, 0x0C); //Enable Rx1 gain table for readback

            Int16[] coefs = new Int16[128];

            for (byte i = 255; i > 128; i--)
            {
                Link.spiWrite(0x500, i);
                index = Link.spiRead(0x50A);

                feGain = Link.spiRead(0x50B);

                extControl = Link.spiRead(0x50C);

                spiReg2     = Link.spiRead(0x50D);
                digGain     = (byte)(spiReg2 & 0x7F);
                enableAtten = (byte)(spiReg2 >> 7);

                Console.WriteLine(index + ", " + feGain + ", " + extControl + ", " + digGain + ", " + enableAtten);
            }

            Link.spiWrite(0x516, 0x08); //Enable Rx1 gain table for readback

            Link.Disconnect();
        }
Esempio n. 8
0
        public static void ReadFirFilter()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            byte spiReg1 = 0;
            byte spiReg2 = 0;

            Link.spiWrite(0x00A, 0x84); //Enable readback of RX1 FIR
            spiReg1 = Link.spiRead(0x00A); Console.WriteLine("Scratch Reg Test: " + spiReg1.ToString("X"));
            Link.spiWrite(0xDFF, 0x84); //Enable readback of RX1 FIR
            spiReg1 = Link.spiRead(0xDFF); Console.WriteLine("Filter Select: " + spiReg1.ToString("X"));

            spiReg1 = Link.spiRead(0x410); Console.WriteLine("Rx #taps: " + (spiReg1).ToString("X"));
            spiReg1 = Link.spiRead(0x411); Console.WriteLine("Rx Filter Gain: " + (spiReg1 & 0x03).ToString("X"));
            spiReg1 = Link.spiRead(0x412); Console.WriteLine("DPD Rx Filter Gain: " + (spiReg1 & 0x03).ToString("X"));
            Console.WriteLine("Sniffer Rx Filter Gain: " + ((spiReg1 >> 5) & 0x03).ToString("X"));

            Int16[] coefs = new Int16[128];

            for (int i = 0; i < 128; i++)
            {
                Link.spiWrite(0xE01, (byte)(i * 2));
                spiReg1 = Link.spiRead(0xE00);
                Link.spiWrite(0xE01, (byte)(i * 2 + 1));
                spiReg2 = Link.spiRead(0xE00);

                coefs[i] = (Int16)((UInt16)(spiReg1) | ((UInt16)(spiReg2) << 8));
                Console.WriteLine("Coef[" + i + "]: " + coefs[i]);
            }



            Link.Disconnect();
        }
Esempio n. 9
0
        public static void TestMykonosSerializerPrbs()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            Link.spiWrite(0xDC0, 0x3);    //hold obsRx framer in reset
            Link.spiWrite(0xDC7, 0x00);   //Disable lane FIFOs in ObsRx framer
            Link.spiWrite(0xDC1, 0x00);   //disable ObsRx framer clocks

            Link.fpgaWrite(0x400, 0x400); //Enable all Rx and Tx lanes in FPGA
            Link.fpgaWrite(0x40C, 0xE4E4E4);
            Link.spiWrite(0x78, 0x00);    //Lane polarity
            Link.spiWrite(0x72, 1);       //enable prbs 20
            Link.spiWrite(0xB1, 0x90);    //enable all serializer lanes
            //Link.spiWrite(0xB3, 0x20); //slow down lane rate by /2
            //Link.spiWrite(0x11A, 0x00); //divide serializer some

            Link.fpgaWrite(0x404, 0x08); //Clear Error counters
            Link.fpgaWrite(0x404, 0x01); //enable PRBS7 checker

            Link.fpgaWrite(0x404, 0x11); //Enable PRBS7 error counters

            UInt32 fpgaReg = 0;
            byte   spiReg  = 0;

            spiReg = Link.spiRead(0x059); Console.WriteLine("SPI Reg x059 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x05A); Console.WriteLine("SPI Reg x05A = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x060); Console.WriteLine("SPI Reg x060 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x061); Console.WriteLine("SPI Reg x061 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x062); Console.WriteLine("SPI Reg x062 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x059); Console.WriteLine("SPI Reg x059 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x110); Console.WriteLine("SPI Reg x110 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x0B3); Console.WriteLine("SPI Reg x0B3 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x11A); Console.WriteLine("SPI Reg x11A = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x0B0); Console.WriteLine("SPI Reg x0B0 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x0B1); Console.WriteLine("SPI Reg x0B1 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x0B2); Console.WriteLine("SPI Reg x0B2 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x0B3); Console.WriteLine("SPI Reg x0B3 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x0B4); Console.WriteLine("SPI Reg x0B4 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x0B5); Console.WriteLine("SPI Reg x0B5 = " + spiReg.ToString("X"));
            spiReg = Link.spiRead(0x224); Console.WriteLine("RCAL result = " + spiReg.ToString("X"));

            fpgaReg = Link.fpgaRead(0x404); Console.WriteLine("FPGA Reg x404 = " + fpgaReg.ToString("X"));
            fpgaReg = Link.fpgaRead(0x41C); Console.WriteLine("FPGA Reg x41C = " + fpgaReg.ToString("X"));
            fpgaReg = Link.fpgaRead(0x420); Console.WriteLine("FPGA Reg x420 = " + fpgaReg.ToString("X"));
            fpgaReg = Link.fpgaRead(0x14); Console.WriteLine("FPGA Reg x14 = " + fpgaReg.ToString("X"));

            Link.Disconnect();
        }
Esempio n. 10
0
        public static void TestMCS()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            byte mcsStatus = 0;

            Link.setSpiChannel(1);
            Link.spiWrite(0x120, 0x00);

            Link.Mykonos.enableMultichipSync(1, ref mcsStatus);

            Link.Ad9528.requestSysref(true);
            Link.Ad9528.requestSysref(true);
            Link.Ad9528.requestSysref(true);
            Link.Ad9528.requestSysref(true);

            Link.Mykonos.enableMultichipSync(0, ref mcsStatus);
            Link.Disconnect();
        }
Esempio n. 11
0
        public static void ORxGainSweep([Values(Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO, Mykonos.OBSRXCHANNEL.OBS_RX2_TXLO)] Mykonos.OBSRXCHANNEL channel)
        {
            //Initialize param structure with Hardcoded Values
            double[] profileInfo      = Helper.SetOrxProfileInfo(channel);
            double   samplingFreq_MHz = profileInfo[0] / 1000;
            double   freqLo_MHz       = profileInfo[1] / 1000000;
            double   profileBW_MHz    = profileInfo[2] / 1000000;
            double   testFreq         = 2510;
            double   amplitude_dBm    = -20;

            string[] pcbInfo;

            //TODO: Hard coded, may want to read the gain tables instead if custom ones are loaded
            //Number of known indicies in the gain index table.
            //Should a customer provide a custom gain table, we should determine the number of valid gain indicies
            // and this array size should correspond to that number.
            int numIndices = 19;

            double[,] amplitudeData     = new double[numIndices, 3];
            double[,] amplitudeDiffData = new double[numIndices - 1, 2];
            short[] rxDataArray = new short[16384];
            Console.WriteLine("Detected LO Frequency: " + freqLo_MHz);
            Console.WriteLine("Profile BW: " + profileBW_MHz);

            switch (channel)
            {
            case Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO:
            case Mykonos.OBSRXCHANNEL.OBS_RX2_TXLO:
                testFreq = freqLo_MHz + 10;
                break;

            case Mykonos.OBSRXCHANNEL.OBS_SNIFFER_A:
            case Mykonos.OBSRXCHANNEL.OBS_SNIFFER_B:
            case Mykonos.OBSRXCHANNEL.OBS_SNIFFER_C:
                testFreq      = freqLo_MHz + 5;
                amplitude_dBm = -30;
                break;
            }

            //ESG Configuration
            SG_AgilentESG esg = new SG_AgilentESG(measEquipment.ESGAddress);

            Console.WriteLine(measEquipment.ESGAddress);
            Console.WriteLine(esg.Identify());
            esg.SetFrequency(testFreq);
            esg.SetAmplitude(amplitude_dBm);
            esg.SetRfOutput(true);

            //Test Sequence
            byte gainIndex = 255;
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            AdiMath.FftAnalysis analysisData = new AdiMath.FftAnalysis();

            for (int i = 0; i < (numIndices + 1); i++)
            {
                try
                {
                    Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
                    Link.spiWrite(0x4F1, 0x80);
                    gainIndex = (byte)(255 - i);
                    Console.WriteLine("Initial gain index = " + Link.Mykonos.getObsRxGain());
                    Link.Mykonos.setObsRxManualGain(channel, gainIndex);    //There is currently an error in the API.
                    Console.WriteLine("Set gain index = " + gainIndex);
                    System.Threading.Thread.Sleep(100);
                }
                catch (Exception e)
                {
                    //Console.WriteLine("Invalid Gain index reached" + i);    //Need to figure out a better way to exit the loop when invalid gain reached
                    Console.WriteLine(e);
                    break;
                }
                finally
                {
                    Link.Disconnect();
                }


                rxDataArray = Helper.MykonosOrxCapture(channel, 8192); //Grab data from the FPGA
                byte     sampleBitWidth = 16;
                double[] data           = AdiMath.complexfftAndScale(rxDataArray, samplingFreq_MHz, sampleBitWidth, true, out analysisData);

                amplitudeData[i, 0] = (double)gainIndex;
                amplitudeData[i, 1] = analysisData.FundamentalPower_dBFS;
                if (i == 0)
                {
                    amplitudeData[i, 2] = analysisData.FundamentalPower_dBFS;
                }
                else
                {
                    amplitudeData[i, 2]         = amplitudeData[i - 1, 2] - 1;
                    amplitudeDiffData[i - 1, 0] = (double)gainIndex;
                    amplitudeDiffData[i - 1, 1] = amplitudeData[i - 1, 1] - amplitudeData[i, 1];
                    Console.WriteLine(" Gain index :" + amplitudeDiffData[i - 1, 0]);
                    Console.WriteLine(" Differential Amplitude" + amplitudeDiffData[i - 1, 1]);
                }
            }


#if WR_RES_TO_PDF
            string path = ObsRxRfTests.ResPath + "ORxGainSweep";
            if (channel == Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO)
            {
                path = path + "OBS_RX1_TXLO";
            }
            else
            {
                path = path + "OBS_RX2_TXLO";
            }
            var doc1 = new Document();
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[2];
            string[] timeLabels = new string[] { "Rx Gain Sweep versus Amplitude for " + channel.ToString(),
                                                 "Gain Index (byte)",
                                                 "Amplitude (dBFS)",
                                                 "Amplitude: " + amplitude_dBm + "dBm",
                                                 "Perfect 1dB Gain Index Steps" };
            string[] timeLabels2 = new string[] { "Difference between consecutive gain entries " + channel.ToString(),
                                                  "Gain Index",
                                                  "Amplitude delta (dB, comparing A(n + 1) - A(n))",
                                                  "Amplitude: " + amplitude_dBm + "dBm" };
            pcbInfo = Helper.PcbInfo();

            container[0] = Helper.MakeChartObject(amplitudeData, timeLabels, path);
            container[1] = Helper.MakeChartObject(amplitudeDiffData, timeLabels2, path + "2");

            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);
            //Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
            for (int i = 1; i < (numIndices); i++)
            {
                NUnit.Framework.Assert.IsTrue(((amplitudeDiffData[i - 1, 1] < 1) &&
                                               (amplitudeDiffData[i - 1, 1] > 0)));
            }
#endif
        }
Esempio n. 12
0
        public static void TxLoopbackRx1Rx2Capture(int amp_dbm1,
                                                   int OffSet1,
                                                   int IQExptVal1,
                                                   int amp_dbm2,
                                                   int OffSet2,
                                                   int IQExptVal2)
        {
            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] rxprofileInfo = new double[3];
            rxprofileInfo[0] = settings.rxProfileData.IqRate_kHz;
            rxprofileInfo[1] = settings.rxPllLoFreq_Hz;
            rxprofileInfo[2] = settings.rxProfileData.PrimarySigBw_Hz;

            double[] txprofileInfo = new double[3];
            txprofileInfo[0] = settings.txProfileData.IqRate_kHz;
            txprofileInfo[1] = settings.txPllLoFreq_Hz;
            txprofileInfo[2] = settings.txProfileData.PrimarySigBw_Hz;


            double samplingFreq_Hz = rxprofileInfo[0] * 1000;
            double profileBW_MHz   = rxprofileInfo[2] / 1000000;

            Console.WriteLine("Rx Sampling Freq (Hz): " + samplingFreq_Hz);
            Console.WriteLine("Rx Profile Bandwdith (MHz): " + profileBW_MHz);
            double freqLo_kHz = rxprofileInfo[1] / 1000;

            Console.WriteLine("Rx LO Frequency (kHz): " + freqLo_kHz);



            //Define DataCapture Parameters
            const int NUM_SAMPLES = 8192;

            short[] rx1DataArray = new short[NUM_SAMPLES * 2];
            double[,] rx1timeDomainData = new double[NUM_SAMPLES / 2, 3];

            short[] rx2DataArray = new short[NUM_SAMPLES * 2];
            double[,] rx2timeDomainData = new double[NUM_SAMPLES / 2, 3];



            //Enable Mykonos Rx and Tx Datapaths
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
#if false    //Debug To check Test works- messup ADC Sampler Crossbar
            byte dataRb;
            dataRb = Link.spiRead(0x082);
            Console.Write(dataRb.ToString("X"));
            Link.spiWrite(0x082, 0xF0);
            dataRb = Link.spiRead(0x082);
            Console.Write(dataRb.ToString("X"));
#endif
#if false    //Debug To check Test works- messup Lane Crossbar
            byte dataRb;
            dataRb = Link.spiRead(0x083);
            Console.Write(dataRb.ToString("X"));
            Link.spiWrite(0x083, 0xE0);
            dataRb = Link.spiRead(0x083);
            Console.Write(dataRb.ToString("X"));
#endif
            Link.Mykonos.radioOn();
            Link.Disconnect();

            //Generate Loopback Tone
            Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1, txprofileInfo, OffSet1 * 100000, amp_dbm1);
            Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX2, txprofileInfo, OffSet2 * 100000, amp_dbm2);


            //Capture Rx Data Tone
            System.Threading.Thread.Sleep(500);
            rx1DataArray = Helper.MykonosRxCapture(Mykonos.RXCHANNEL.RX1, NUM_SAMPLES);
            rx2DataArray = Helper.MykonosRxCapture(Mykonos.RXCHANNEL.RX2, NUM_SAMPLES);

            //Frequency Domain Data Processing for Rx1
            AdiMath.FftAnalysis analysisData = new AdiMath.FftAnalysis();
            double   samplingFreq_MHz        = samplingFreq_Hz / 1000000;
            byte     sampleBitWidth          = 16;
            double[] data = AdiMath.complexfftAndScale(rx1DataArray, samplingFreq_MHz, sampleBitWidth, true, out analysisData);

            //Define the 2D array to store frequency bins corresponding to fft data
            double[,] fftFreqAmp = new double[data.Length, 2];
            double binSize = (samplingFreq_MHz / NUM_SAMPLES);
            double minFreq = samplingFreq_MHz / 2 * (-1);
            for (int i = 0; i < data.Length; i++)
            {
                fftFreqAmp[i, 0] = minFreq + (binSize * 2 * i);
                fftFreqAmp[i, 1] = data[i];
            }

            //Time Domain Data Processing
            int numSamplesDiv2 = (int)NUM_SAMPLES / 2;
            for (int i = 0; i < numSamplesDiv2; i++)
            {
                rx1timeDomainData[i, 0] = i;
                rx1timeDomainData[i, 1] = rx1DataArray[2 * i];
                rx1timeDomainData[i, 2] = rx1DataArray[2 * i + 1];
            }

            //Frequency Domain Data Processing for Rx2
            data = AdiMath.complexfftAndScale(rx2DataArray, samplingFreq_MHz, sampleBitWidth, true, out analysisData);

            //Define the 2D array to store frequency bins corresponding to fft data
            fftFreqAmp = new double[data.Length, 2];
            binSize    = (samplingFreq_MHz / NUM_SAMPLES);
            minFreq    = samplingFreq_MHz / 2 * (-1);
            for (int i = 0; i < data.Length; i++)
            {
                fftFreqAmp[i, 0] = minFreq + (binSize * 2 * i);
                fftFreqAmp[i, 1] = data[i];
            }

            //Time Domain Data Processing
            numSamplesDiv2 = (int)NUM_SAMPLES / 2;
            for (int i = 0; i < numSamplesDiv2; i++)
            {
                rx2timeDomainData[i, 0] = i;
                rx2timeDomainData[i, 1] = rx2DataArray[2 * i];
                rx2timeDomainData[i, 2] = rx2DataArray[2 * i + 1];
            }

            //Check IQ Data For Rx1
            var IMin = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => rx1timeDomainData[i, 1]).Min();
            var IMax = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => rx1timeDomainData[i, 1]).Max();
            var QMin = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => rx1timeDomainData[i, 2]).Min();
            var QMax = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => rx1timeDomainData[i, 2]).Max();
            Console.WriteLine("I Max, Min:" + IMax.ToString() + "," + IMin.ToString());
            Console.WriteLine("Q Max, Min:" + QMax.ToString() + "," + QMin.ToString());
            NUnit.Framework.Assert.Greater(IMin, ((-1) * (IQExptVal1 + ((IQExptVal1 * 10) / 100))));
            NUnit.Framework.Assert.Less(IMin, (IQExptVal1 * (-1)));
            NUnit.Framework.Assert.Less(IMax, ((IQExptVal1 + ((IQExptVal1 * 10) / 100))));
            NUnit.Framework.Assert.Greater(IMax, IQExptVal1);

            NUnit.Framework.Assert.Greater(QMin, ((-1) * (IQExptVal1 + ((IQExptVal1 * 10) / 100))));
            NUnit.Framework.Assert.Less(QMin, (IQExptVal1 * (-1)));
            NUnit.Framework.Assert.Less(QMax, ((IQExptVal1 + ((IQExptVal1 * 10) / 100))));
            NUnit.Framework.Assert.Greater(QMax, IQExptVal1);

            //Check IQ Data For Rx2
            IMin = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => rx2timeDomainData[i, 1]).Min();
            IMax = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => rx2timeDomainData[i, 1]).Max();
            QMin = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => rx2timeDomainData[i, 2]).Min();
            QMax = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => rx2timeDomainData[i, 2]).Max();
            Console.WriteLine("I Max, Min:" + IMax.ToString() + "," + IMin.ToString());
            Console.WriteLine("Q Max, Min:" + QMax.ToString() + "," + QMin.ToString());
            NUnit.Framework.Assert.Greater(IMin, ((-1) * (IQExptVal2 + ((IQExptVal2 * 10) / 100))));
            NUnit.Framework.Assert.Less(IMin, (IQExptVal2 * (-1)));
            NUnit.Framework.Assert.Less(IMax, ((IQExptVal2 + ((IQExptVal2 * 10) / 100))));
            NUnit.Framework.Assert.Greater(IMax, IQExptVal2);

            NUnit.Framework.Assert.Greater(QMin, ((-1) * (IQExptVal2 + ((IQExptVal2 * 10) / 100))));
            NUnit.Framework.Assert.Less(QMin, (IQExptVal2 * (-1)));
            NUnit.Framework.Assert.Less(QMax, ((IQExptVal2 + ((IQExptVal2 * 10) / 100))));
            NUnit.Framework.Assert.Greater(QMax, IQExptVal2);


#if false
            string path = JesdRfTests.ResPath + "Rx_JESD_FFT_TimeDomain_Plots";
            path = path + "RX2";

            string[] timeLabels = new string[] { "Time Domain Response of " + "RX2", "Sample Number", "ADC Codes", "I data", "Q data" };
            string[] fftLabels  = new string[] { "Frequency Domain Response of " + "RX2", "Frequency (MHz)", "Amplitude (dBFS)", "FFT DATA" };                                                                                        // Should be >=4 long.

            var doc1 = new Document();
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[2];
            container[0] = Helper.MakeChartObject(rx2timeDomainData, timeLabels, path);
            container[1] = Helper.MakeChartObject(fftFreqAmp, fftLabels, path);
            string[] pcbInfo;
            pcbInfo = Helper.PcbInfo();

            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);

            // open result pdf
            System.Diagnostics.Process.Start(path + ".pdf");
#endif
        }
        public static void RxFramerInjectPrbsErrorCheck([Values(Mykonos.MYK_PRBS_ORDER.PRBS7, Mykonos.MYK_PRBS_ORDER.PRBS15, Mykonos.MYK_PRBS_ORDER.PRBS31)] Mykonos.MYK_PRBS_ORDER PrbsOrder)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            UInt32 fpgaData        = 0;
            byte   mykData         = 0;
            UInt32 FpgaLane0ErrCnt = 0;
            UInt32 FpgaLane1ErrCnt = 0;

            mykData = Link.spiRead(0x78); Console.WriteLine("SPI Reg x78 = " + mykData.ToString("X"));

            //Initialise System and JESD Links
            TestSetup.PrbsRxTestSetupInit(settings);
            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            fpgaData = Link.fpgaRead(0x410);
            Console.WriteLine("FPGA Reg x410: REFCLK Frequency Detect = 0x" + fpgaData.ToString("X") + " = " + fpgaData.ToString());
            fpgaData = Link.fpgaRead(0x10);
            Console.WriteLine("FPGA Version x10:" + fpgaData.ToString("X"));

            //Enable PRBS Test Mode ON Mykonos and FPGA
            //Clear FPGA PRBS counters
            //Then Check error count is 0 following some delay
            Link.Mykonos.enableRxFramerPrbs(PrbsOrder, 1);
            fpgaData = Link.fpgaRead(0x404);
            switch (PrbsOrder)
            {
            case Mykonos.MYK_PRBS_ORDER.PRBS7:
                fpgaData |= 0x1;
                break;

            case Mykonos.MYK_PRBS_ORDER.PRBS15:
                fpgaData |= 0x2;
                break;

            case Mykonos.MYK_PRBS_ORDER.PRBS31:
                fpgaData |= 0x4;
                break;

            default:
                Assert.Fail("Invalid PRBS Order");
                break;
            }
            //GTX PRBS Check Counter + GTX PRBS Config
            //Disable PRBS Error Counter Reset
            //Read Counters for Lane 0 & 1
            //Check Reset Was Successful
            //Let PRBS Checker Run
            //Check there are no errors
            Link.fpgaWrite(0x404, fpgaData | 0x18);
            fpgaData = Link.fpgaRead(0x404);
            Link.fpgaWrite(0x404, (fpgaData & 0xFFFFFFF7));
            fpgaData = Link.fpgaRead(0x404);
            Console.WriteLine("FPGA Reg 0x404 = " + fpgaData.ToString("X"));

            fpgaData = Link.fpgaRead(0x41C);
            Console.WriteLine("FPGA Reg 0x41C = " + fpgaData.ToString("X"));
            Assert.AreEqual(fpgaData, 0x0);

            System.Threading.Thread.Sleep(5000);
            fpgaData = Link.fpgaRead(0x41C);
            Console.WriteLine("FPGA Reg 0x41C = " + fpgaData.ToString("X"));
            FpgaLane0ErrCnt = (fpgaData & 0xFFFF);
            FpgaLane1ErrCnt = (fpgaData >> 16);
            Console.WriteLine("FPGA Lane 0 Error = " + FpgaLane0ErrCnt.ToString("X"));
            Console.WriteLine("FPGA Lane 1 Error = " + FpgaLane1ErrCnt.ToString("X"));
            Assert.Less(FpgaLane0ErrCnt, 0x1);
            Assert.Less(FpgaLane1ErrCnt, 0x1);

            //Reset Counters

            Link.spiWrite(0xA5, 0xF9);                      //enable prbs checker in Mykonos, clear error counters
            Link.spiWrite(0xA5, 0xF1);                      //enable prbs checker in Mykonos
            Link.fpgaWrite(0x404, (fpgaData | 0x8));        //Reset PRBS Error Counter
            fpgaData = Link.fpgaRead(0x404);
            Link.fpgaWrite(0x404, (fpgaData & 0xFFFFFFF7)); //Reset PRBS Error Counter
            fpgaData = Link.fpgaRead(0x404);
            Console.WriteLine("FPGA Reg 0x404 = " + fpgaData.ToString("X"));

            //Start Injecting Prbs Errors
            //Then Check FPGA error count
            Link.Mykonos.rxInjectPrbsError();
            System.Threading.Thread.Sleep(1000);

            fpgaData = Link.fpgaRead(0x41C);
            Console.WriteLine("FPGA Reg 0x41C = " + fpgaData.ToString("X"));
            Link.Mykonos.rxInjectPrbsError();
            System.Threading.Thread.Sleep(1000);
            Link.Mykonos.rxInjectPrbsError();
            System.Threading.Thread.Sleep(1000);
            fpgaData = Link.fpgaRead(0x41C);
            Console.WriteLine("FPGA Reg 0x41C = " + fpgaData.ToString("X"));
            FpgaLane0ErrCnt = (fpgaData & 0xFFFF);
            FpgaLane1ErrCnt = (fpgaData >> 16);
            Console.WriteLine("FPGA Lane 0 Error = " + FpgaLane0ErrCnt.ToString("X"));
            Console.WriteLine("FPGA Lane 1 Error = " + FpgaLane1ErrCnt.ToString("X"));
            Assert.LessOrEqual(FpgaLane0ErrCnt + FpgaLane1ErrCnt, 0x3);
            Assert.GreaterOrEqual(FpgaLane0ErrCnt + FpgaLane1ErrCnt, 0x1);

            Link.Disconnect();
        }