 |
 |
| View previous topic :: View next topic |
| Author |
Message |
benoitstjean
Joined: 30 Oct 2007 Posts: 605 Location: Ottawa, Ontario, Canada
|
|
Posted: Mon Jul 25, 2016 10:09 am |
|
|
Ok, I think *maybe* I confused you guys regarding pin D0 and INT0...
First, I have 5 external interrupts: one for the SD card (INT0 on pin 46) and 4 external triggers (INT1-4 on other pints) for whatever the user ties to them (sensor with on/off signal, external switch etc).
On my current PIC24HJ256GP206, pin D0 (46) is being used as a 128 KHz PWM output. Pin F6 (35) is used as one of my external input interrupts and turns-out that it's INT0 - INT0 is a function of F6.
I now want to replace that PIC 24HJ with the 24EP because of the RAM and ROM space (much more). The entire device is pin-to-pin compatible other than the EP pins are remappable.
However, the INT0 'functionality' is the problem:
--> It has been moved from PIN F6 (24HJ) to PIN D0 (24EP)
--> PIN D0 is *already* being used as an external PWM output
Like if you buy a car radio and the radio manufacturer decides that the volume control on the old radio model, which was a knob, now needs to be controlled by the gas pedal on the new radio model... And that knob on the new radio is just for on/off... Anyways, kind'of an analogy... so the functionality of INT0 has been ported from one pin to another and that *other* pin I am already using as a PWM output....
So... On the NEW PIC (24EP512GP806), pin D0 (46) is now INT0 and pin F6 (35) is no longer an external interrupt.
Bottom line: as far as I can tell, I cannot use PIN F6 as an external interrupt anymore unless it can be used as a CN pin... but I'm not too sure if it's do-able.
Since the signal from the SD socket is still tied to F6 on the circuit and that pin can no longer be used as an external interrupt (even as a CN pin I think), then the only way I can tell if this pin is high or low is by reading it on a timer.
I have many units in the field therefore I will try to avoid recalling them to make hardware changes.
Benoit |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20061
|
|
Posted: Mon Jul 25, 2016 10:58 am |
|
|
Why on earth use interrupts for these....
Any switch/pin, needs to be debounced. Have a single timer interrupt at (say) 100Hz, and then poll the pins in this, and if it is 'on' for two cycles, then do what you want to have triggered by the pins.
Trying to work out what you want an interrupt for an SD card for?. The only switches on these are the card being present, and the WP switch. Both of these are normally simply polled inside the driver code. You don't want the waste of time and space involved in an interrupt for these. |
|
 |
benoitstjean
Joined: 30 Oct 2007 Posts: 605 Location: Ottawa, Ontario, Canada
|
|
Posted: Mon Jul 25, 2016 12:42 pm |
|
|
I know that switches need to be debounced. I could use timers also... but I mean, what is the purpose of the external interrupts really? They are here for the purpose of detecting external signals changing state at any point in time. I did not disclose what my device is doing and what field it is used in so perhaps I do need external interrupts...?!
My device processes a huge amount of data in realtime over I2C, SPI, UART through DMA over a TDM bus etc so I figured that using the external interrupts only when a state change gets detected would help the code (rather than polling on a timer, thus allocate that time to the realtime stuff).
When I said "detect external switches", I gave that as an example just so I did not want to go into details... but in my world it would be more like sensors that provide a signal when something is detected from different sources. These signals would not be mechanical activations but rather electrical signals therefore debouncing, in this case, would not be required. The device is also tested before every scenario to make sure the installation works as expected.
I do have a debounce timer that gets started when the INT pin is triggered and when the said timer expires, I read the input again to see if it's still high (or low depending on which edge I trigger).
Anyhow, what I have works for me and works very well.
I guess I will use the timer for the SD card detection pin.
Thanks for your time and help.
Cheers!
Benoit |
|
 |
jeremiah
Joined: 20 Jul 2010 Posts: 1411
|
|
Posted: Mon Jul 25, 2016 2:50 pm |
|
|
| Out of curiosity, why would the CN interrupt not work for you? For as simple a task as you described, it should work almost exactly like an external interrupt. |
|
 |
benoitstjean
Joined: 30 Oct 2007 Posts: 605 Location: Ottawa, Ontario, Canada
|
|
Posted: Tue Jul 26, 2016 4:46 am |
|
|
Ha! Good question! You know why? To be totally honest, I did not really realize that the PIC24E was capable of doing so because the PIC24H pins are explicitely marked as CNIx on every pin that can do it and the concept of remappable pins is new to me.
Don't forget that based on my initial message that spawned this thread, I had just found out about the PIC24E and pin mapping then two days later I left for holidays and came back yesterday. I realize that someone (perhaps you) mentioned it but then I left and did not investigate this option (actually forgot about it!).
On the PIC24H, pin F6 (the problematic pin) cannot do CNI because it is not explicitely marked but in the PIC24E datasheet, I just saw on page 3 that "Every I/O port pin (RAx-RGx) can be used as change notification".
Definitely I will try that today.
Thanks again!
Benoit |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|