View previous topic :: View next topic |
Author |
Message |
ccmcca
Joined: 08 Oct 2005 Posts: 13
|
1 us |
Posted: Wed Jun 13, 2007 2:54 pm |
|
|
Hello i am working with a GPS module that have 1 pps and the duration of it pulse is 1 MICRO SEG (1us).
The question is ....
Can i capture this little pulse with the RB0 of my 18f252, with an external interrupt as #INT_EXT???
How long must be the pulse, for capture on #INT_EXT of my pic???
THANKS
Excuse me but i speak spanish.... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 13, 2007 3:21 pm |
|
|
This information is in the PIC data sheet. Look near the end, in the
section on "Electrical Characteristics". In Table 22-6, it shows the Tinp
parameter: "INT pin high or low time". The minimum value is Tcy.
Tcy is 1/4 of the oscillator frequency. So for a 1 us pulse, you need
a minimum PIC oscillator frequency of 4 MHz. It's probably safer if
you ran the PIC at a higher frequency, because maybe your input
pulse is not always at 1 us. What if it's 0.9 us, sometimes ?
It's safer if you run the PIC at 8 MHz or more. |
|
|
ccmcca
Joined: 08 Oct 2005 Posts: 13
|
|
Posted: Wed Jun 13, 2007 4:52 pm |
|
|
I have a 10 Mhz osc with 4xx - 40Mhz
But i cant detect this pulse.
I dont know whath's going on... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 13, 2007 4:57 pm |
|
|
What are the voltage levels of the pulse ? (high and low levels). |
|
|
ccmcca
Joined: 08 Oct 2005 Posts: 13
|
|
Posted: Wed Jun 13, 2007 5:02 pm |
|
|
0v LOW
2.85V HIGH |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 13, 2007 5:21 pm |
|
|
What's the Vdd of your PIC ?
If it's +5v, the minimum Vih voltage for the INT_EXT pin is 4.0 volts. |
|
|
ccmcca
Joined: 08 Oct 2005 Posts: 13
|
|
Posted: Wed Jun 13, 2007 5:40 pm |
|
|
Yes it is 5v.
What i have to do ....put some pullup or a transistor....?
THANK!!!!!!!!! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
ccmcca
Joined: 08 Oct 2005 Posts: 13
|
|
Posted: Wed Jun 13, 2007 6:48 pm |
|
|
MUCHAS GRACIAS AMIGO
THANK A LOT!!!!!!!!!!!!!!!!!!!!!!!!1 |
|
|
RossJ
Joined: 25 Aug 2004 Posts: 66
|
|
Posted: Thu Jun 14, 2007 8:19 am |
|
|
Another solution you might consider is to simply use the port B interrupt on change capability of RB4-RB7. They have the same timing capability as INTx but are TTL input buffered instead of Schmitt Trigger. As a result, the minimum logic high level is only 2.0v instead of the 4.0v of a ST input (assuming Vcc is 5.0v).
The 2.85v you mention should be more than enough to directly drive RBx. The only thing to consider is whether the 2.85v output can ever be lower than 2.0v whilst driving high. Hopefully the GPS module datasheet can tell you this. |
|
|
ccmcca
Joined: 08 Oct 2005 Posts: 13
|
Good |
Posted: Thu Jun 14, 2007 9:46 am |
|
|
Ok I wil tried with the RB4....
Because less components is much better.
Thanks |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
Re: Good |
Posted: Thu Jun 14, 2007 10:26 am |
|
|
ccmcca wrote: | Ok I wil tried with the RB4....
Because less components is much better.
Thanks | The problem with B4 to B7 is that a change on any of these pins configured as an input will trigger the interrupt-on-change event. This shouldn't be a problem as long as you take notice of this.
My datasheet for the PIC18F252 notes int-ext as a smitt-trigger input when configured for interrupt usage..... Am I missing something? |
|
|
RossJ
Joined: 25 Aug 2004 Posts: 66
|
|
Posted: Thu Jun 14, 2007 7:49 pm |
|
|
You're not missing anything... that's exactly the point. Because ext0/1/2 pins are Schmitt triggered they are incompatible. Only pins with TTL inputs are suitable.
I have this problem when connecting 3.3v radio comms modules to the PIC because the USART RXD pin is always Schmitt Trigger buffered. So I need a level converter. When I use a 'software UART', I can use TTL pins and no level converter is required.
/Ross. |
|
|
RossJ
Joined: 25 Aug 2004 Posts: 66
|
|
Posted: Thu Jun 14, 2007 8:05 pm |
|
|
Also, your point about the RB4-7 all triggering interrupt on change events is a good one. The best solution is to configure the remaining 3 pins as outputs (whether you use them or not). This ensures they have no impact on the GPS module pulse detection.
One more thing... since RB4-7 is 'on change' and not rising/falling edge triggered, you may get an interrupt for both edges. This is unlikely to be the case with a pulse of only 1us, even at 40MHz system clock. But it could be an issue if the pulse can be longer (or you poll the flag and clear it immediately). A simple solution to ensure this is never a problem is to wait for the pulse to finish before clearing the interrupt flag. This can be done regardless of whether you use polling or interrupts.
/Ross. |
|
|
|