I'm using P0.1, P1.0, P1.1, P2.0 as output pins. I noticed that all these pins go to logic HIGH state just after power on. I checked on oscilloscope to confirm this. This is just momentary, just until I set the pins to LOW at the *end* of the function SimpleBLEPeripheral_Init():
// makes sure LEDs are off HalLedSet( (HAL_LED_1 | HAL_LED_2), HAL_LED_MODE_OFF ); P0SEL = 0; // Configure Port 0 as GPIO P1SEL = 0; // Configure Port 1 as GPIO P2SEL = 0; // Configure Port 2 as GPIO
//kdp P0DIR = 0xFC; // Port 0 pins P0.0 and P0.1 as input (buttons), all others (P0.2-P0.7) as output P0DIR = 0xFF; // (P0.0-P0.7) as output P1DIR = 0xFF; // All port 1 pins (P1.0-P1.7) as output P2DIR = 0x1F; // All port 1 pins (P2.0-P2.4) as output //kdp P0 = 0x03; // All pins on port 0 to low except for P0.0 and P0.1 (buttons) P0 = 0; // All pins on port 0 to low P1 = 0; // All pins on port 1 to low P2 = 0; // All pins on port 2 to low
Is the default state of all CC2540 PIO pins HIGH? Is there a way to keep them LOW at power ON?
Thanks for your time and best regards,
After reset all the IOs are configured as inputs. Measuring HIGH on IOs suggests that some other
code configuring these IOs to act as output HIGH, In BLE stuck you can look for default board
Default is inputs with pull-ups enabled, which is why they measure high. The pull-ups are to stop the inputs floating and causing excessive shoot-through current in the IO fets. If you want them low configure as low outputs.
@Eng351, @Igor Sherer,
Thanks for your replies. I am checking the board default configuration and trying a few things.
Why would you hit the verify button so soon? I am still checking and I will verify an answer when I get this problem solved. Thank you!
I verified the answer because what Eng351 wrote about the default GPIO configuration is correct. This information can also be found in the CC253x/4x Users Guide.
It is great that you will verify answers once you have confirmed they are working. Unfortunately not everybody does this, so threads tend to stay un-verified even though the original question(s) are answered.
--PS. If I answered your question, please hit Verify Answer !
To elaborate Eng351's answer:
The default state of GPIOs when the chip is in reset (as it is during power up) is as inputs with pull-ups. There is no way to change this. As soon as the chip is fully powered up you can configure the pins to whatever you want.
Thanks everyone for helping out so quickly!
Fredrick, appreciate your additional information. So the earliest that I can set the pins LOW is in "hal_board_cfg.h" in HAL_BOARD_INIT(). Despite this I do see a momentary HIGH on the pins when the board is switched ON. Just have to live with it.
I'll leave Eng351's answer as the verified answer where he first mentioned the default state to be INPUT with pull-ups.
PS: I have relays connected to these 4 pins. The side-effect of this momemtary HIGH is that the relays switch ON for a little bit on Power Up. Is there any way to prevent this? Anything I could do in hardware?
Thanks again, Kapil
There could be a couple of hardware options, the background for these suggestions is the knowledge that the internal pull up resistor on the pad is 23k.
1) You could place an external resistor to ground that is much smaller than 23k, you would want to make sure the resistor was small enough that the resistive divided voltage appearing at the pin input is not around mid rail and causing excessive shoot through current to the input buffer of the chip. The downside to this solution is that when you are outputting a high on the pin then there will be a lot of wasted current through the external resistor.
2) You could place external NMOS FETs which would have their gate control connect to another GPIO and the drain connected to the GPIO connected to the relay. During power up you are assured that the FET gate control will be high thus causing the GPIO lines in question to be pulled down. Once in a powered up state you would want to make sure the FET gate control was set to low. For this solution you will have to ensure the external FET threshold voltage and rdson are appropriate, though I would think you'd have a lot of options.
I know both of these are a little painful but maybe one will work for you.
Hi Kapil, I assume you have a transistor between the I/O and the relay. You can add a voltage divider between the I/O and transistor base / gate to load down the pull up resistor and also ensure your transistor only switches when the I/O is high. If you are using an NPN and VCC = 3V, i would use say a 5K6 and 2K2:
Thank you BugKing, Eng351!
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.