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?
Period Of A Sinewave?
Re: Period Of A Sinewave?
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.
But you can also use any of the port 0 pins as an interrupt which is allowed by the LPC175x series parts.
Re: Period Of A Sinewave?
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.
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.
Re: Period Of A Sinewave?
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 don't need absolute timing from this, just reasonable data.
Re: Period Of A Sinewave?
If I use Timer0 to measure time, and clock it directly with PCLK(25Mhz?), then each bit is 0.040 microseconds. Is that correct?
Re: Period Of A Sinewave?
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?
Re: Period Of A Sinewave?
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
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
Re: Period Of A Sinewave?
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
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
Re: Period Of A Sinewave?
If you are not seeing interrupts--
is the interrupt enabled?
does the pending interrupt status bit show an interrupt pending?
is the interrupt enabled?
does the pending interrupt status bit show an interrupt pending?
Re: Period Of A Sinewave?
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.
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.