View previous topic :: View next topic |
Author |
Message |
CatchDbug Guest
|
Odd behavior with RB6 and RB7 as digital Inputs |
Posted: Wed Oct 11, 2006 8:25 am |
|
|
The used Microcontroller is 16F877A, with no LVP or DEBUG fuses activated in the CCS or in the Melab EPIC.
I have 4 switches connected to ports RB4:RB7, each switch with an external pullup and a grounded capacitor for stabilize bounces. The switches are normally open and graounded in the other side.
The RB interrupt is properly enabled.
When I detect a change on RB at the interupt handler I send an integer to identify the pushed button to the PC. (using printf in the CCS and a MAX232 as hardware).
When the interrupt occurs in RB4 or RB5 the microcontroller responds properly, but sometimes suffers a reset or stops responding when it occurs in RB6 or RB7. (previous facts where verifeid ).
I guess the microcontroller stills entering LVP or ICD modes even if the fuses are disabled ...
I may post some code in few hours.
Any suggestion is welcomed.
Thank You |
|
![](templates/subSilver/images/spacer.gif) |
KamPutty Guest
|
|
Posted: Wed Oct 11, 2006 10:12 am |
|
|
Are you also using RB6:RB7 for the printf function? If so, could that be an issue with sharing the pins?
~Kam (^8* |
|
![](templates/subSilver/images/spacer.gif) |
CatchDbug Guest
|
|
Posted: Wed Oct 11, 2006 10:20 am |
|
|
KamPutty wrote: | Are you also using RB6:RB7 for the printf function? If so, could that be an issue with sharing the pins?
~Kam (^8* |
Of course not, I am using the USART of PortC for that command, ![Wink](images/smiles/icon_wink.gif) |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Wed Oct 11, 2006 10:26 am |
|
|
Try disconnecting a capacitor from RB6 or RB7 and then see if you still have a problem with that input. If the Capacitor / Resistor time constant is too long and the power supply is noisy then you could see inputs toggle because in IOC mode these are not schmidt trigger inputs. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 11, 2006 1:01 pm |
|
|
Quote: | The used Microcontroller is 16F877A, with no LVP or DEBUG fuses activated in the CCS or in the Melab EPIC. |
Not sure I like the way you phrased that. If you "don't activate"
the LVP fuse, as shown below, it will in fact be enabled.
Code: | #fuses XT, NOWDT, NOPROTECT, PUT, BROWNOUT |
The above line of code will create this result in the .LST file:
Quote: |
Configuration Fuses:
Word 1: 3FF1 XT NOWDT PUT NOPROTECT BROWNOUT LVP NOCPD NOWRT NODEBUG |
To disable the LVP mode you must put in the NOLVP fuse.
Quote: |
Sometimes suffers a reset or stops responding when it occurs in RB6 or RB7. |
The first step would be to put a 0.1 uF (100 nF) capacitor between
each Vdd pin on the PIC and ground. Many people report that this
fixes the "random reset" problem. |
|
![](templates/subSilver/images/spacer.gif) |
CatchDbug Guest
|
|
Posted: Wed Oct 11, 2006 6:23 pm |
|
|
PCM programmer,
Of course I have in my fuses NOLVP and NODEBUG, sorry for not posting my fuses. And the programmer software reading the configuration from file and programming it every time.
My capacitor between Vdd ans Vss is 1000uF, but I doubt that the size difference between the suggested capacitor and the used one is the cause due that the controller is never reset when I use similar switches in RB4:5 . I will try changing it any way.
The microcontroller can detect without problem about 10 interrupts comming from RB7 (I/O and Serial Programming Data) and almost none from RB6 (I/O and Serial Programing Clock) That is why I guess it still entering in LVP.
Thanks for your help, I will give you more info soon. |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Wed Oct 11, 2006 6:46 pm |
|
|
CatchDbug wrote: | PCM programmer,
My capacitor between Vdd ans Vss is 1000uF, but I doubt that the size difference between the suggested capacitor and the used one is the cause due that the controller is never reset when I use similar switches in RB4:5 . I will try changing it any way. |
Do you also have 10 to 100nF decoupling capacitors as close as possible to the PIC's VDD and VSS? These are essential for reliable operation of the PIC. A rule of thumb is a minumum of one per IC. On larger, more complex PICs, and implementations with Analog inputs, you would expect to see a decooupling capacitor for every VDD/VSS pair of connections on the PIC. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 11, 2006 7:14 pm |
|
|
Electrolytic capacitors are basically only good for audio frequencies
and a little bit above that (up to 100 KHz).
A ceramic 0.1 uF capacitor will be good for at least up to 10 MHz.
It's important to put a 0.1 uF capacitor between every Vdd pin
and ground. Put them very close to the pin. |
|
![](templates/subSilver/images/spacer.gif) |
CatchDbug Guest
|
|
Posted: Wed Oct 11, 2006 7:27 pm |
|
|
Thanks guys, problem solved with 10nF capacitor near Vdd and Vss of the microcontroller. |
|
![](templates/subSilver/images/spacer.gif) |
CatchDbug Guest
|
|
Posted: Wed Oct 11, 2006 8:48 pm |
|
|
After some time turned on the circuit start behaving as before again Noise/Capacitor related problem
I took out the capacitor of RB7 and the interrupt from it started to behave properly, did the same with RB6 and the cicuit started to behave as before. The problem is related to the schmit trigger of the inputs and how to couple it with the switch. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 11, 2006 8:59 pm |
|
|
What was the value of the capacitors that you had on those pins ?
Also, what's the value of the pull-up resistors ? |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Wed Oct 11, 2006 9:03 pm |
|
|
The capacitors on the switch help with the debouce problem and also to stop a spurious spike being interpretted as a change. A very small value of CR will help but is not necessary, the rest can be handled in software.
In the IOC handler you read the current value of the port and save it as a candidate. You start a 20ms timer. If during this 20ms another IOC happens you just repeat the process. Enentually the 20ms timer will timeout causeing a timer interrupt. What ever the last candidate value was is now the debouced value. You now check this will the original (not the candiate) value. If the "debounced" value and the original value are the same then nothing happened - it was just noise. If they aer different then the debounced value becomes the new original value. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Wed Oct 11, 2006 9:41 pm |
|
|
Quote: |
What was the value of the capacitors that you had on those pins ? |
Initial 1uF, Actual 10nF
Quote: |
Also, what's the value of the pull-up resistors ? |
10k Ohm |
|
![](templates/subSilver/images/spacer.gif) |
CatchDbug Guest
|
|
Posted: Thu Oct 12, 2006 10:05 pm |
|
|
The problem was finally solved using for coupling the switch the circuit suggested by microchip to for coupling the reset. Use a pullup of with 10k Ohm a grounded capacitor of 1uF in parallel with the switch. And a resistor of 1 kOhm between RB6 and the switch
**************************************************
***************10k Ohm--- 5V*******************
***************** | *****************************
RB6 >-------1kOhm----+-------Push button---GND*********
*****************|******************************
*************** 1uF --- GND *************** ****
**************************************************
Thanks for the help |
|
![](templates/subSilver/images/spacer.gif) |
|