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

disable mcu pins

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



Joined: 06 Oct 2008
Posts: 43

View user's profile Send private message

disable mcu pins
PostPosted: Thu Jan 06, 2011 1:58 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 06, 2011 8:23 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 06, 2011 7:47 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 06, 2011 10:17 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 06, 2011 11:47 pm     Reply with quote

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. Smile Please help.
mbradley



Joined: 11 Jul 2009
Posts: 118
Location: California, USA

View user's profile Send private message Visit poster's website

PostPosted: Fri Jan 07, 2011 12:50 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jan 07, 2011 6:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jan 07, 2011 11:01 am     Reply with quote

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.
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