CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Odd behavior with RB6 and RB7 as digital Inputs

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
CatchDbug
Guest







Odd behavior with RB6 and RB7 as digital Inputs
PostPosted: Wed Oct 11, 2006 8:25 am     Reply with quote

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
KamPutty
Guest







PostPosted: Wed Oct 11, 2006 10:12 am     Reply with quote

Are you also using RB6:RB7 for the printf function? If so, could that be an issue with sharing the pins?

~Kam (^8*
CatchDbug
Guest







PostPosted: Wed Oct 11, 2006 10:20 am     Reply with quote

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
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Oct 11, 2006 10:26 am     Reply with quote

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!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 11, 2006 1:01 pm     Reply with quote

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.
CatchDbug
Guest







PostPosted: Wed Oct 11, 2006 6:23 pm     Reply with quote

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) Arrow That is why I guess it still entering in LVP.

Thanks for your help, I will give you more info soon.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Oct 11, 2006 6:46 pm     Reply with quote

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!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 11, 2006 7:14 pm     Reply with quote

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.
CatchDbug
Guest







PostPosted: Wed Oct 11, 2006 7:27 pm     Reply with quote

Thanks guys, problem solved with 10nF capacitor near Vdd and Vss of the microcontroller.
CatchDbug
Guest







PostPosted: Wed Oct 11, 2006 8:48 pm     Reply with quote

After some time turned on the circuit start behaving as before again Arrow 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. Arrow The problem is related to the schmit trigger of the inputs and how to couple it with the switch.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 11, 2006 8:59 pm     Reply with quote

What was the value of the capacitors that you had on those pins ?

Also, what's the value of the pull-up resistors ?
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Oct 11, 2006 9:03 pm     Reply with quote

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!!
Guest








PostPosted: Wed Oct 11, 2006 9:41 pm     Reply with quote

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
CatchDbug
Guest







PostPosted: Thu Oct 12, 2006 10:05 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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