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

Changing trisa causes reset

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



Joined: 19 May 2018
Posts: 27

View user's profile Send private message

Changing trisa causes reset
PostPosted: Mon Jun 08, 2020 10:47 am     Reply with quote

Using a 18F46K22 the device during initialization resets/loses flow when I change trisa values with a 2.5 uf cap from pin a0 to pin a1. If i remove the cap or even put a short from a0 to a1 it works fine.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jun 08, 2020 11:00 am     Reply with quote

Please post a small, compilable program that shows this happening.
gtx15



Joined: 19 May 2018
Posts: 27

View user's profile Send private message

PostPosted: Mon Jun 08, 2020 5:00 pm     Reply with quote

Code:

#include <erase.h> 

void main()
{

while(TRUE)
   {
    set_tris_b (0x0f);
    set_tris_c (0x80);
    set_tris_d (0xb0);
    set_tris_e (0x0);
    set_tris_a (0x00);  //crashes here!

    while (1)
       {
        delay_ms(22);
        led = 1;
        delay_ms(44);
        led = 0;

        //TODO: User Code
       }
   }
}

Code:

////////////////////////////////  erase.h

#include <18F46K22.h>
#device ADC=10

#FUSES NOWDT                    //No Watch Dog Timer
#bit led = 0xf83.3         //pin d3

#use delay(internal=64000000)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Changing trisa causes reset
PostPosted: Mon Jun 08, 2020 5:48 pm     Reply with quote

gtx15 wrote:

when I change trisa values with a 2.5 uf cap from pin a0 to pin a1.

It's not a good circuit design method to connect a cap between two i/o
pins. Especially not a big cap in the uF range. My suspicion is when you
pull the i/o pins down to 0v quickly, you may be generating a current or
voltage transient inside the PIC that is causing it to reset or to hang.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jun 08, 2020 6:46 pm     Reply with quote

Those pins might have analog peripherals on them like ADC or comparator. Without disabling those peripherals and then using tris... I'm unsure what will happen.
Kinda obvious the PIC isn't 'happy'. As PCM P points out , I agree excessive current flowing where it shouldn't and the PIC halts.
Hopefully you haven't damaged 'something' inside !

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Tue Jun 09, 2020 1:41 am     Reply with quote

Also (of course), a lot may depend on the other connections round
the chip.
If there is no reservoir capacitor close to the chip, and you then switch
what is instantaneously an overload on the chip, the supply itself might
be drooping.
Remember you can of course limit the maximum current involved
with a resistor. 100R, ensures that 5v, won't exceed the maximum
current rating of the output pins.
However I'd be suspicious of the other effect - raising the pin voltage
above Vdd, or taking it below Vss. This is the 'difference' between a
capacitor and a short.
Think about it you have pin 1 at 0v, and pin 2 at 5v. You then raise pin 1
to 5v. The effect it to momentarily take Pin 2 up to effectively 10v....
The capacitor becomes a charge pump at the moment you switch. This
will be clamped by the internal protection diodes into the supply rail.
Result will depend on the nature of the supply, and what overvoltage
clamping it has. Also the protection diodes inside the chip are not rated to
handle this.
The maximum current rating of an output pin, on this chip is 50mA. The
maximum current rating of the protection diodes is 20mA. So the
diode will be overloaded by a factor of more than 2*.... This is why
MicroChip very carefully specify that these are 'last ditch' protection only,
and if you have an input that needs to actually be clamped within the
rails, you need to provide your own diodes external to the chip.....
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