Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to avoid 12f675 to be too sensitive (EMI ?)

Status
Not open for further replies.

TropicalMonkey

New Member
Hello everyone!

I am very new to MCU programming. In order to try out the free HITECH compiler I built a MCU's "Hello, World" program that is to blink an LED. I got the code from somewhere on the internet and compiled and programmed 12f675 successfully. The LED does blink .. well almost. Apparently it is too sensitive to the EMI. The LED blinking might start and stop for no reason. Initially I suspected my el cheapo bread-board. But it turned that when I am sitting at my desk with the bread-board blinking LED on the desk, I can turn that off by simply lifting my feet from the ground - and vice versa. It looks like it is suffering from EMI or floating inputs. I tried to change all GPIO to outputs and that did not solve the issue. But if I leave all GPIOs as inputs and pull them up to +VDD, it just works fine. Is that normal? Or am I missing something?

Oh! by the way, here is the program I got from internet:

Code:
// Copyright (c) 2005, K9spud LLC.
// http://www.k9spud.com/hoodmicro/

__CONFIG(INTIO & WDTDIS & PWRTEN);

#define bitset(var, bit) ((var) |= 1 << (bit))
#define bitclr(var, bit) ((var) &= ~(1 << (bit)))

#define LED_PIN 4

void main(void)
{
	unsigned int i;
  
	INTCON = 0; // disable interrupts
	TRISIO = ~(1 << LED_PIN); // configure all pins as inputs, except the LED_PIN
	//TRISIO = 0;

	OSCCAL = _READ_OSCCAL_DATA(); // restore oscillator calibration

	for(;;)
	{
		bitset(GPIO, LED_PIN); // turn the LED on
		for(i = 0; i < 10000; ++i)
		{
			// do nothing, busy wait loop
		}
		
		bitclr(GPIO, LED_PIN); // turn the LED off
		for(i = 0; i < 10000; ++i)
		{
			// do nothing, busy wait loop
		}
	}
}
 
It's not good practice to have MCU pins floating. Perhaps u should switch them to all digital inputs except GPIO3 and enable weak pull ups. USe GPIO3 to blink the LED.

Have u used a 100nF capacitor across the MCU VDD/VSS pins? That stabilizes the pwr supply and prevents odd resets.

Are u using a regulated supply?

The bit about your feet and the ground sounds like induction on an ADC input or a tristated input floating, but could be a bad system ground as well being influenced by your body capacitance.

Edit:
How have u set up the Mclr pin?
 
Last edited:
I did not have the capacitor across the power supply. I was powering it from AA cells.

Edit:

The circuit behaved the same way even after adding a ceramic capacitor across VDD/VSS.

But pulling the MCLR to VDD driven away the ghost in the circuit! It now works as intended (even with the simplest wiring with no capacitor across VDD/VSS). GP3 at Pin#4 is always input in this MCU and the same pin is also MCLR.

Now, it is time to read more about MCLR.

Thanks guys!
 
Last edited:
MCLR is the master clear pin, which will cause the PIC to reset if it is floating, it should always be pulled up or disabled if using as input.

Wilksey
 
12f675 document says, that pin must be pulled up to VDD using RC network. The document further says "An internal MCLR option is enabled by setting the MCLRE bit in the Configuration Word. When enabled, MCLR is internally tied to VDD. No internal pull-up option is available for the MCLR pin". (that is a little confusing).

I used MCLRDIS as part of the __CONFIG and now it works with no pull up to VDD! I am not sure if that is the real fix. (Pulling up MCLR to VDD does fix the problem, but I am trying to find an optimum solution).

--TropicalMonkey
 
Last edited:
12f675 document says, that pin must be pulled up to VDD using RC network. The document further says "An internal MCLR option is enabled by setting the MCLRE bit in the Configuration Word. When enabled, MCLR is internally tied to VDD. No internal pull-up option is available for the MCLR pin". (that is a little confusing).

I used MCLRDIS as part of the __CONFIG and now it works with no pull up to VDD! I am not sure if that is the real fix. (Pulling up MCLR to VDD does fix the problem, but I am trying to find an optimum solution).

--TropicalMonkey
You fixed it with this MCLRDIS if it's not disabled it will reset if not pulled up with a 10k resistor.
 
Status
Not open for further replies.

Latest threads

Back
Top