View previous topic :: View next topic |
Author |
Message |
overmindx
Joined: 06 Oct 2008 Posts: 43
|
disable mcu pins |
Posted: Thu Jan 06, 2011 1:58 am |
|
|
Hi, is there a way to disable/enable a pin in an mcu? How can I do this? Please help. Thanks in advance. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Jan 06, 2011 8:23 am |
|
|
What do you mean by "disable"? You can make a pin an input. Then it won't try to drive anything. But even an input pin should not be allowed to float with nothing driving it as that may cause excess power consumption and noise. Generally unused pins are set as outputs. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
overmindx
Joined: 06 Oct 2008 Posts: 43
|
|
Posted: Thu Jan 06, 2011 7:47 pm |
|
|
hi.. thanks for the reply.. i have two pins C6 and C7 that i use to communicate serially with my pc.. what i want is to have a control to disable and enable these pins.. so basically, if they are disable, they wont be able to send and receive data from the pc.. how can i do this? please help.. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Jan 06, 2011 10:17 pm |
|
|
This seems like an odd request... Normally if you don't want a PIC to send data you simply don't instruct it to send the data. Are you worried about some virus or malicious software leaking secure information?
Here are some quick ideas:
If you are using UART interrupts you could simply mask the UART interrupts.
You could put a software lock inside the UART interrupt handlers.
You could set the UART baud rate to something ridiculous.
You could frequently set the output pin high (Stop bit) to mangle any outgoing byte.
Tell us more about your application. What PIC are you using? _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
overmindx
Joined: 06 Oct 2008 Posts: 43
|
|
Posted: Thu Jan 06, 2011 11:47 pm |
|
|
Hi, in my firmware, I placed printf statements for debugging purposes and to know exactly what the system is doing. What I want is have a way to disable these serial pins if my board is not connected to the PC. It's because I've noticed though not sure about this, that if you have a serial communication and nothing is connected in it, the continuous output of data such as the use of printf causes erratic behavior. So to be sure, I just want to disable these pins if it is not connected to a PC. I hope I made sense in what I just wrote. Please help. |
|
|
mbradley
Joined: 11 Jul 2009 Posts: 118 Location: California, USA
|
|
Posted: Fri Jan 07, 2011 12:50 am |
|
|
Short answer no.
However, this is a software issue, don't use them.
I too use alot of output during debugging, but I do a define, and on final compile, I comment it out.
Code: |
#define DEBUG
#ifdef DEBUG
printf(.....);
#endif
|
If you don't want to do that, then still do it in software, requires another pin for use:
Code: |
if (input(PIN_XX) == 1)
{
printf(....);
}
|
On your serial connector, tie PIN_XX to something, tie it low with a 1k resistor, and then tie it to the DTR serial like or something. _________________ Michael Bradley
www.mculabs.com
Open Drivers and Projects |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Fri Jan 07, 2011 6:04 am |
|
|
As a separate comment, sending serial, with nothing connected, won't cause a problem.
I'd be more suspicious that the input line is generating continuous or random receive data. Depending how your receive 'handling' is done, this could cause problems.
Best Wishes |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Fri Jan 07, 2011 11:01 am |
|
|
Try disabling the INT_RDA when not needed. I think I've found that a floating RX pin and an enabled INT_RDA, can generate continuous interrupts that cause problems.
Or you can just add a pull-up. |
|
|
|