• AVR Freaks

Helpful ReplyHot!Internal pull up resistor for switch on digital Input

Author
Killerpiraat
Starting Member
  • Total Posts : 68
  • Reward points : 0
  • Joined: 2020/03/09 07:40:17
  • Location: 0
  • Status: offline
2020/05/29 02:17:27 (permalink)
0

Internal pull up resistor for switch on digital Input

Hello,
 
I am using a PIC16F15354 on my homemade PCB, and i have 1 switch mounted on the PCB. 
 
 
I connected the switch to ground because the microchips have internal pull ups (right???!!!!). I have made the simplest program to test if the switch is working, but it doesnt work.
 
It doesnt respond to the switch. Its stays in the "LOW" position. There is a led connected on port A0 and that just stays on when i press, or let go of the switch.
When i manually connect 5V to pin RC2 the led turns of. 
My question: Do i have to set the internal pull up resistor somewhere in the software? I assumed this should happen automatticly.
 
When i measure in the beep mode of my DMM there is no connection on pin RC2 to GND when the switch is released. If the switch is pressed RC2 is connected to GND.
 
See attachments
post edited by Killerpiraat - 2020/05/29 02:19:29

Attached Image(s)

#1
du00000001
Just Some Member
  • Total Posts : 3778
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Internal pull up resistor for switch on digital Input 2020/05/29 02:29:42 (permalink) ☄ Helpfulby Killerpiraat 2020/05/29 02:45:32
+1 (1)
You're really havin ideas. And illusions.
About nothing is happening "automatically" on a microcontroller, certainly not activating some pullup resistor on I/O pins. So you'll have to configure that one by software - provided there is one available to be configured.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#2
Killerpiraat
Starting Member
  • Total Posts : 68
  • Reward points : 0
  • Joined: 2020/03/09 07:40:17
  • Location: 0
  • Status: offline
Re: Internal pull up resistor for switch on digital Input 2020/05/29 02:46:51 (permalink)
0
Haha, thanks for your reply. Offcourse, i understand. But with previous projects (i used to curiosity board for testing, before designing the PCB) i never had to set the internal pull ups on IO pins. So how do i set the internal pull ups in MPLAB?
 
EDIT:
 
THis is what i meant. I assume this is the place that tells the uC to activate the internal weak pull ups? Offcourse it doesnt active those automaticly, but what i meant was the software activated those for me when i generated the project.
 
The pull ups are enabled right? Is it possible my input pin doesnt have an internal pull up? I cannot find it in the datasheet.
post edited by Killerpiraat - 2020/05/29 02:56:35

Attached Image(s)

#3
ric
Super Member
  • Total Posts : 27633
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Internal pull up resistor for switch on digital Input 2020/05/29 03:02:21 (permalink)
+1 (1)
Killerpiraat
The pull ups are enabled right? Is it possible my input pin doesnt have an internal pull up? I cannot find it in the datasheet.

Really?
You totally missed section "14.6.7 WEAK PULL-UP CONTROL" in the datasheet?
It is right where you would expect it, in the PORTC GPIO chapter.
 
post edited by ric - 2020/05/29 03:03:56

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#4
Killerpiraat
Starting Member
  • Total Posts : 68
  • Reward points : 0
  • Joined: 2020/03/09 07:40:17
  • Location: 0
  • Status: offline
Re: Internal pull up resistor for switch on digital Input 2020/05/29 03:05:08 (permalink)
0
ahhhhhh, so i guess only port B have pull ups? Thanks RIc
 
EDIT: No wait there is also a chapter for portC. Sorry i didnt read very good. But can you agree that i alreade enabled the internal weak pull ups in the software (earlier post)
post edited by Killerpiraat - 2020/05/29 03:06:54
#5
ric
Super Member
  • Total Posts : 27633
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Internal pull up resistor for switch on digital Input 2020/05/29 03:08:47 (permalink)
+1 (1)
Killerpiraat
Sorry i didnt read very good. But can you agree that i alreade enabled the internal weak pull ups in the software (earlier post)

Where?
I don't see any code from you writing to the WPUC register.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#6
Killerpiraat
Starting Member
  • Total Posts : 68
  • Reward points : 0
  • Joined: 2020/03/09 07:40:17
  • Location: 0
  • Status: offline
Re: Internal pull up resistor for switch on digital Input 2020/06/02 00:52:28 (permalink)
0
ric
Killerpiraat
Sorry i didnt read very good. But can you agree that i alreade enabled the internal weak pull ups in the software (earlier post)

Where?
I don't see any code from you writing to the WPUC register.
 




in the second reaction in this threat (third post)
 
And here:
post edited by Killerpiraat - 2020/06/02 00:55:39

Attached Image(s)

#7
Killerpiraat
Starting Member
  • Total Posts : 68
  • Reward points : 0
  • Joined: 2020/03/09 07:40:17
  • Location: 0
  • Status: offline
Re: Internal pull up resistor for switch on digital Input 2020/06/02 01:07:50 (permalink)
0
Im so sorry, i got it. Offcourse i should have called the SWITCH_SetPullup in my main as a sort of initialize. Thanks for your time once again!
#8
ric
Super Member
  • Total Posts : 27633
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Internal pull up resistor for switch on digital Input 2020/06/02 01:42:26 (permalink)
+1 (1)
That is NOT code writing to WPUC.
It is a macro which will insert that code, IF YOU USE THAT MACRO  SOMEWHERE IN YOUR CODE.
As I already said, you have not shown any code that actually does it.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#9
ric
Super Member
  • Total Posts : 27633
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Internal pull up resistor for switch on digital Input 2020/06/02 01:44:32 (permalink) ☄ Helpfulby Avinash_1588 2020/06/07 00:49:04
+3 (3)
Killerpiraat
Im so sorry, i got it. Offcourse i should have called the SWITCH_SetPullup in my main as a sort of initialize.

You don't CALL a macro.
That makes it sound like a funciton, which it is not.
You INVOKE it by placing the macro somewhere in your code.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#10
Jump to:
© 2020 APG vNext Commercial Version 4.5