Period Of A Sinewave?

Questions on other types of hardware and getting it talking to the ARM CPU
danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Period Of A Sinewave?

Post by danlee58 »

I need to determine the Period of a Sinewave, using a SuperPro. My present strategy calls for a Comparator IC used as a Zero Crossing Detector, and generating an Interrupt that reads and resets Timer0.

The problem with this is I have no access to the External Interrupts on the SuperPro from a Shield where my Comparator IC is located. EINT0(P2.10) is being used for LoadC.

Another approach is to use an A/D converter and trigger an Interrupt on the change of the sign bit, but I am using AD2, AD3(DAC), AD4, and AD5 for other purposes. AD6 & AD7 are being used for serial ports.

Is there another way to do this, or am I missing something?



basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Period Of A Sinewave?

Post by basicchip »

P2.10 EINT0 is driven by the Coridium USB dongle, but you could use it if you disconnect that pin (suggestions on how to do that in the help files). You just have to make sure whatever circuitry you add there allows that line to be high during reset otherwise it enters the ISP download mode and won't run your program.

But you can also use any of the port 0 pins as an interrupt which is allowed by the LPC175x series parts.

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: Period Of A Sinewave?

Post by danlee58 »

I read that about using a P0.x pin as an Interrupt, but I couldn't find any description of the process.

I could do it by setting Timer0 up to Capture a transition on an Input Pin. Do I need an Interrupt to reset the TC, or can I have the TC reset by the Capture Control Register?

I could do it in software, if I subtract the old Capture Register value from the new Capture Register value. A non-zero result would be the period of the last cycle. That would mean that I don't need any interrupts at all. Rollover would need to be taken into account.

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: Period Of A Sinewave?

Post by danlee58 »

Pin P1.18 looks like a good candidate for a Capture. It uses CAP1.0.

I don't need absolute timing from this, just reasonable data.

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: Period Of A Sinewave?

Post by danlee58 »

If I use Timer0 to measure time, and clock it directly with PCLK(25Mhz?), then each bit is 0.040 microseconds. Is that correct?

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: Period Of A Sinewave?

Post by danlee58 »

danlee58 wrote:Pin P1.18 looks like a good candidate for a Capture. It uses CAP1.0.

I don't need absolute timing from this, just reasonable data.

I have verified that I get pulses on P1.18, but my Interrupt procedure doesn't run. Did I miss a PCB_PINSEL definition?

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: Period Of A Sinewave?

Post by danlee58 »

Here is my Pinsel code:

PCB_PINSEL1 = 0x240000; //Selects AD2 on P0.25, & DAC on P0.26
PCB_PINSEL3 = 0xF0000030; //Selects AD4 on P1.30, & AD5 on P1.31 & CAP 1.0 on P1.18

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: Period Of A Sinewave?

Post by danlee58 »

Here is my Timer0 Capture setup code:

T0_PR = 0; //Set Prescale Register so TC will increment at the full clock rate(25MHz)
T0_CTCR = 0; //Set Timer Mode & Select CAPn.0 for Capture pin
T0_CCR = 5;//Set Capture Control Register for rising edge and generate Interrupt
T0_TCR = 2; //Reset Timer 0
T0_TCR = 1; //Enable Timer 0

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Period Of A Sinewave?

Post by basicchip »

If you are not seeing interrupts--

is the interrupt enabled?

does the pending interrupt status bit show an interrupt pending?

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: Period Of A Sinewave?

Post by danlee58 »

The Interrupt Set-Enable Register0 reads 0x22.

The VICIntSetPend0 reads 410000?

I am using a test setup that I lashed together. I need to set it up in the equipment to be sure that P1.18 hass a rising edge. I'll try tomorrow.

Post Reply