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

Turn off MCLR weak pull up on pic18F46k22

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



Joined: 25 Feb 2004
Posts: 28

View user's profile Send private message

Turn off MCLR weak pull up on pic18F46k22
PostPosted: Wed Jun 01, 2016 7:49 am     Reply with quote

Hello,

Can anybody help me with this problem. I am using a max803 supply monitor for controlling the MCLR line on a PIC 18F46k22.
To isolate the mclr line from the max803 for programming I have a diode between the reset line of the MAX803 and the MCLR line of the PIC with the anode on the MAX803 side. I'm using a 22k pull up from the MAX803 reset pin and a 300k pull down on the MCLR line.

My problem is that when I look on the scope the MCLR line is coming up straight away in time to the supply and not waiting for the ~300mS the MAX803 should be forcing it to do. I'm fairly sure it is due to the weak pull up on the MCLR line reverse biasing the diode but for the life of me I cannot see how to turn it off.

I've created a small program to try to turn off the pull ups but no success.

Using CCS compiler 4.130 with the following code:
Code:

#include <18F46K22.h>
#device ICD=TRUE
#device adc=16

#FUSES NOWDT                 
#FUSES WDT128                   
#FUSES INTRC_IO               
#FUSES NOFCMEN                 
#FUSES NOIESO               
#FUSES PUT                   
#FUSES NOBROWNOUT         
#FUSES WDT_NOSLEEP       
#FUSES NOLVP                   
#FUSES NOXINST                 
#FUSES MCLR         //<<<<<< use MCLR line as MCLR           

#use delay(int=16000000,RESTART_WDT)



void main() {
   setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
   setup_timer_4(T4_DISABLED,0,1);
   setup_timer_5(T5_DISABLED | T5_DIV_BY_1);
   setup_timer_6(T6_DISABLED,0,1);

   setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard

   port_e_pullups(false);   //<<<<<<<<<< even tried this to turn off weak pull ups
   
   while(TRUE){
      //TODO: User Code
   }

}

Can anybody please tell me why the weak pull ups will not turn off?

Thanks for any help.

Sandy W
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Wed Jun 01, 2016 7:57 am     Reply with quote

#device ICD=TRUE

This says that the MCLR line is to be used by the ICD.

You can't use the MCLR line as a conventional MCLR whilst also using the ICD.
sandy wilson



Joined: 25 Feb 2004
Posts: 28

View user's profile Send private message

PostPosted: Wed Jun 01, 2016 8:07 am     Reply with quote

Thanks for the quick reply Ttelmah,

tried removing the #device ICD=true section and I'm still getting the same effect.
temtronic



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

View user's profile Send private message

PostPosted: Wed Jun 01, 2016 8:33 am     Reply with quote

hmm.. if using MPLAB, be sure to compile as 'release' and NOT 'debug'. That's another snake that will bite you !

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Wed Jun 01, 2016 8:36 am     Reply with quote

But are you connecting an ICD?.

The unit controls the pin so long as it is connected.

How are you compiling this?.

Are you using MPLAB?.

If so, this will default to re-setting the ICD settings, unless you select for it to compile for 'release'.

The pullup, won't cause your problem. Why should it?. Understand the FET is there all the time, even if turned off, but the pin can be happily pulled down and up (the pullup only delivers about 90uA).

It cannot be turned off. read the data sheet:
"When the RE3 port pin is configured as
MCLR, (CONFIG3H<7>, MCLRE=1 and
CONFIG4L<2>, LVP=0), or configured for Low Voltage
Programming, (MCLRE=x and LVP=1), the pull-up is
always enabled and the WPUE3 bit has no effect."

So the pullup will be enabled, since you have the pin set as MCLR. However your monitor is able to sink 20mA. No problem.

Your diode is your problem. How can the 803, ever pull the reset line 'down'?.

Just connect the 803, directly to the reset line on the PIC, get rid of all resistors, and let the pull-up do it's job.

If you are intending to use an ICD, then have a jumper to disconnect the circuit.
sandy wilson



Joined: 25 Feb 2004
Posts: 28

View user's profile Send private message

PostPosted: Wed Jun 01, 2016 8:56 am     Reply with quote

Quote:
But are you connecting an ICD?.
--- The ICD_U40 is connected for programming and then removed from the circuit and the PIC is run as normal

Quote:
How are you compiling this?.
Are you using MPLAB?.
--- Compiling in CCS IDE and then using CCS Load to program the chip. MPLAB is not used at all.


Quote:
It cannot be turned off. read the data sheet:
"When the RE3 port pin is configured as
MCLR, (CONFIG3H<7>, MCLRE=1 and
CONFIG4L<2>, LVP=0), or configured for Low Voltage
Programming, (MCLRE=x and LVP=1), the pull-up is
always enabled and the WPUE3 bit has no effect."

So the pullup will be enabled, since you have the pin set as MCLR. However your monitor is able to sink 20mA. No problem.

--- Yep, read this till I was blue in the face, just miss interpreted it

Quote:
Your diode is your problem. How can the 803, ever pull the reset line 'down'?.
Just connect the 803, directly to the reset line on the PIC, get rid of all resistors, and let the pull-up do it's job.

-- the 300k pull down on the cathode of the diode (on the MCLR line) I thought should pull down the MCLR line as shown if fig 5 of microchips TB087
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Thu Jun 02, 2016 1:47 am     Reply with quote

You could do it, but you need much higher currents involved.
You'd need to use something like a 10K pull 'down' on MCLR, which would ensure it is seen as low, even with the internal pull-up in it's most 'extreme' variant (remember always use 'worst case' figures). Then to pull this up to ViH, the reset circuit would need something like a 2K pull-up. Problem then is that you'd still end up needing to have a disconnect jumper to use the ICD, so why not make the circuit simpler and just use the supervisor directly to pull the MCLR down, which is what it is designed to do?.

The supervisor guarantees to start pulling 'down' as soon as the voltage is above 1v (if you look at the graphs, you see a tiny little glitch at this point), so will hold the pin low plenty early enough to ensure the supply has time to stabilise. It's how the circuit is designed to work, and saves parts.....
sandy wilson



Joined: 25 Feb 2004
Posts: 28

View user's profile Send private message

PostPosted: Thu Jun 02, 2016 2:58 am     Reply with quote

The crux of my problem is that can't turn off the weak pull up (should have read the data sheets better). I think I will just remove the diode and pull down resistor and replace the diode with a link to fit after programming and let the 803 do its thing.

Thanks for the help Ttelmah.


Sandyw
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