Problems with Panda II reading digital square signal

Hello at all,

is it possible to read a digital square wave signal @ 100 kHz with Panda II?
I’ve tried everything possible for me to get it running with registers and Pincapture and Interrups, but I always miss pulses in the kHz area.With registers I got the best result but I lost pulses there too.
Will I be able to read the signal in RLP, or should i do this better outside with CPLD with communication over SPI2? Is it possible to use SPI1 and SPI2 at the same time?

Thanks from Germany, I hope somebody can help me out!

Alex

Can you give more details on this? Is it a free running frequency you are measuring or you are decoding data? Have you tried GetPulse method?

Hello Gus,

it is a free running frequency that i get from an RS422 output. I want only measuring the period time to calculate the frequency.

I have not tried the pulse method yet, will try it today or tomorrow.

Thanks!

Hi Gus,

What class does the GetPulse method reside in? Thanks.

Adrian

http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/df6cb306-b2de-9e4f-83f2-056188f4afa8.htm

I got the name wrong. I had to much eggnog last night :slight_smile:

I tried it again with registers and pincapture, but I still get an incorrect result. At 100kHz the Panda shows about 60 Hz more than an oscilloscope.
Furthermore, the frequency displayed by the Panda is not constant, it toggle about several Hz.

Here the code, that I modified from Externally Triggered High Speed Counter:


public static void Frequency()
        {

            //Pinsel0 External Match Register
            Register PINSEL0 = new Register(0xE002C000);
	    PINSEL0.Write(3 << 12);//Timer2
            PINSEL0.Write(3 << 20);//Timer3
            

            //Power Control Register for Timer2 and Timer3
            Register PCONP = new Register(0xE01FC0C4);
	    PCONP.SetBits(1 << 22);//Timer2 on
            PCONP.SetBits(1 << 23);//Timer3 on

            //Pin Function Select Register 1
            Register PINSEL1 = new Register(0xE002C004);
            PINSEL1.SetBits((3 << 14));//set bits 14 and 15

            //Time Control Register Timer2
            T2CR = new Register(0xE0070004);
            T2CR.Write(1);
	    //Time Control Register Timer3
            T3CR = new Register(0xE0074004);
            T3CR.Write(1);
            
            //Prescale Register Timer2
            Register T2PR = new Register(0xE007000C);
            T2PR.Write(1800);
	    //Prescale Register Timer2
            Register T3PR = new Register(0xE007400C);
            T3PR.Write(0);
			

            //Count Control Register Timer3 on An0 input
            Register T3CTCR = new Register(0xE0074070);
            T3CTCR.Write(2 << 0 | 0 << 2);
         
            //Capture Control Register Timer3
            Register T3CCR = new Register(0xE0074028);
            T3CCR.ClearBits(0x07);


            // To reset the counter
            T3CR.SetBits((1 << 1));
            T3CR.ClearBits((1 << 1));

	    //Match Control Register Timer2
            Register T2MCR = new Register(0xE0070014);
            T2MCR.Write(1 << 0);
			
            //Match Control Register Timer3
            Register T3MCR = new Register(0xE0074014);
            T3MCR.Write(1 << 0);
			
	    //Match Register Timer2
            Register T2MR0 = new Register(0xE0070018);
            T2MR0.Write(1000);
			
            // Match Register Timer3
            Register T3MR0 = new Register(0xE0074018);
            T3MR0.Write(5000); // change this value as needed

            //Interrupt register
            T3IR = new Register(0xE0074000);
            T3IR.Write(1 << 0);

            Register EM0 = new Register(0xE007403C);
            EM0.Write(3 << 4);
			
      	    //Count of Timer2
	    Register T2TC = new Register(0xE0070008);
			
            //Count of Timer3
            Register T3TC = new Register(0xE0074008);

            uint unvar1 = 0;
            uint untime1 = 0;
            uint unvar2 = 0;
            uint untime2 = 0;
            uint unFrequency = 0;
           
            while (true)
            {
                unvar1 = T3TC.Read();
                untime1 = T2TC.Read();
                Thread.Sleep(1000);
                unvar2 = T3TC.Read();
                untime2 = T2TC.Read();
                unFrequency = (((unvar2 - unvar1)*10000) / (untime2 - untime1));
                Debug.Print("Frequency: " + unFrequency.ToString());        
                Thread.Sleep(1000);
             
            }
        }