1432 views|0 replies

1663

Posts

0

Resources
The OP
 

Regarding the built-in pull-up resistor when MSP430 IO is used as input! [Copy link]

MCU: MSP430g2553 Evaluation Board
Software:
IARQuestion: Should I add a pull-down resistor when scanning a button with an msp430 microcontroller?
Description: Recently, when I was learning about TI's msp430 microcontroller, I wanted to test the onboard buttons, but I found that there was no pull-up resistor outside the IO. When I controlled P1.3 as input in the code, the IO was in a high-impedance state. I could change the potential of the IO by putting my hand on the IO. I naturally thought that I should add a pull-up resistor to the IO, but on the other hand, why didn't TI add a pull-up resistor when designing this board? Do they want us to add it ourselves? Unscientific! So I searched for related questions on the Internet, and many people added resistors separately. Am I overthinking? Suddenly I saw a blog, and the following is the content of the blog:
Today I helped someone test the msp430f2002, and he made such a request again, input, msp430 internal pull-up, and I habitually said, no, only output can be internally pulled up and down. He is a hardware engineer and is very skeptical. In fact, I am also skeptical.
I carefully read the datasheet of 430 and looked at the internal circuit. Wow, it's true. As a person with a major in telecommunications, I actually made such a conclusion without looking at the internal structure. I was careless.

Whether the pull-up or pull-down is enabled is determined by the REN register, and whether the pull-up or pull-down is enabled is determined by the OUT register. When used as an output, the pull-up or pull-down is automatically selected according to the high or low of OUT. When used as an input, we can also manually pay the OUT register to get the pull-up or pull-down.
After reading the above blog, I suddenly realized it! Thank you very much for the blogger's sharing! It helped me solve the problem! But I feel that the blogger's writing is not specific enough. In order to make everyone understand, I will add it again!
As the blogger said:
The PxREN register controls whether the pull resistor is enabled, and PxOUT determines whether the pull resistor is pulled up or pulled down. The specific working principle is as follows:
When PxDIR=1, the output is PxREN=1. Only the pull resistor works. PxOUT=1 pulls up.
PxOUT=0 pulls down.
PxREN=0 push-pull output has no pull resistor. PxOUT=1 outputs high.
PxOUT=0 outputs low.
When PxDIR=0, the input is PxREN=1. The pull resistor works. PxOUT=1 pulls up.
PxOUT=0 pulls down.
When PxREN=0, the IO is in a high-impedance state. High-impedance state

#include<msp430g2553.h>
void main()
{
WDTCTL=WDTPW+WDTHOLD;
P1DIR=0x0001;
P1REN=BIT3; //input
P1OUT=BIT3; //pull
upwhile(1)
{
if(P1IN&BIT3)
P1OUT|=BIT0;
else
P1OUT&=~BIT0;
}
}
I hope this helps!

This post is from Microcontroller MCU
 

Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list