PIC12F675 Development Board

Thread Starter

RodneyB

Joined Apr 28, 2012
697
I am trying to make a development board for a PIC12F675 and am concerned that something is incorrect in my circuit. I have attached the PCB layout and drawing.

I don't have a problem getting the outputs to come on from the PIC BUT, not for the life of me can I get the Inputs to work. I do not have a switch that isolates the inputs from the outputs as I thought in code that was taken care of. I just need some advice as its horrible not knowing if its a hardware or software problem. If I know my hardware is in order then at least I can concentrate on the code.
 

Attachments

BMorse

Joined Sep 26, 2009
2,675
According to your switch arrangement on the right side, you would have to switch one
to an output, another as an input, then press 2 buttons to get an input.

I would just connect one side of your switch to Vdd since you ready have the inputs pulled low. Atleast the right side anyway.
 

Ian Rogers

Joined Dec 12, 2012
1,136
@BMorse
Although the schematic shows no 5v rail on the three switches... The PCB has the 5v rail attached!!!

Unless of course this is still on a prototype board...
 

takao21203

Joined Apr 28, 2012
3,702
There are a couple of issues here. It is mostly a question of choice but I write my opinion.

1. Stretching out a low pincount device more than neccessary (use a SOIC14).

2. The 12f675 is around for some years- how about a 16f1503/16f1824?

3. You could use WPU (internal pullup) if you use more than one key.

4. How about modern LEDs (either 0805 SMD or high eff. 3mm or Straw hat). They work fine with 2.2k or even 4.7K, and you can short that down with a key (blue LEDs are your friend here with 3V since the level after the resistor is still a H somehow).

5. Why a developement board for a small pincount IC which is not new?

Some specific purpose? My experience with low pin count (8 pin) is for small number of PCBs there is no advantage to a 14pin SOIC or a 20pin TSSOP. Even a TQFP44 (easy to handle) is not much larger.

6. In case of doubt, breadboard with just ONE I/O line until it works properly.

Give as much info about your projecct as possible so forum can find the best solution and write as much information in return as possible.

That mean for instance the source, MPLAB version C compiler version, sillicion issue, programmer, power supply, a photo or two.
 

THE_RB

Joined Feb 11, 2008
5,438
The circuit has a serious fault! If the button is pressed while the PIC output is LOW, it will force 5v into the LOW output pin and damage the PIC.

To fix that I would add a 220 ohm resistor in series with each button.

Then you will also need to increase the LED series resistor to about 1.5k (1k5). The LEDs will still be bright enough. :)
 

tracecom

Joined Apr 16, 2010
3,944
The 12F675 is known for being unstable, which is why Microchip replaced it with the far superior 12F683.

Edited February 9, 2014 to add the following.

The statement above is just my opinion based on what I have read on the internet. Here is an example: http://melabs.com/samples/LABX4-12F675/ \

I consider MELABS to be a reputable source of information about Microchip microcontrollers, and I believe what they posted, but they could be wrong. Other people on the internet have also reported similar problems, but I don't have any infallible and unquestionable proof that any of this is correct, so it's just my opinion.

Microchip lists the 12F675 as still in production, so I was wrong about it having been replaced; superseded would have been a better choice of words. I could also be wrong in my opinion that the internal oscillator is unstable and hard to use. Digi-key sells the 12F675 for $1.21 and the 12F683 for $1.42. For my money, I'll take the 12F683.
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
The 12F675 is known for being unstable, which is why Microchip replaced it with the far superior 12F683.
Ahh, what are you talking about? The 12F675 is still in production, and the 683 was introduced at about the same time.

If there were stability problems with it, wouldn't you think that they would fix it rather quickly?
 

MMcLaren

Joined Feb 14, 2010
861
The circuit has a serious fault! If the button is pressed while the PIC output is LOW, it will force 5v into the LOW output pin and damage the PIC.
Of course we don't know exactly what the original poster has in mind for this circuit but it looks like a standard circuit for using a momentary contact push button switch to emulate a lighted toggle switch. If that's the case then the outputs would never output a low. Instead the output pins would be set as inputs at some debounce interval (20-ms) to sample the active high switches and apply the switch state logic and then switched to either output high (LED on) or left as an input (LED off) to match the switches toggled state. The code might look something like this;

Rich (BB code):
/********************************************************************
 *  main loop                                                       *
 ********************************************************************/

   while(1)
   { delay_ms(25);              // 25-msec sample intervals

  /*                                                                *
   *  Lighted Push Button Switches (emulated toggle switches)       *
   *                                                                *
   *  swnew  ____---____-----___   sample active hi switches        *
   *  swold  _____---____-----__   switch state latch               *
   *  swnew  ____-__-___-____-__   changes, press or release        *
   *  swnew  ____-______-_______   filter out 'release' bits        *
   *  flags  _____-------_____--   toggle flag bits for main        *
   *  trisio -----_______-----__   toggle tris bits for LEDs        *
   *                                                                */
     trisio = 0b00111111;       // set all GPIO pins to inputs
     swnew = gpio;              // sample active hi switches
     swnew ^= swold;            // changes, press or release
     swold ^= swnew;            // update switch state latch
     swnew &= swold;            // filter out 'release' bits
     flags ^= swnew;            // toggle flag bits for main
     gpio = 0b00110111;         // set GPIO output latches
     trisio ^= flags;           // light only active sw LEDs
   }                            //
 }                              //
So, it's difficult to support an opinion that there's a "serious fault", however, until the original poster comes back, we're all just guessing.

Cheerful regards, mike
 

Attachments

Last edited:

tracecom

Joined Apr 16, 2010
3,944
"I saw it on the internet so it must be true". LOL...

Unfortunately, when you present an opinion disguised as an authoritative conclusion instead of a conclusion based on an argument that includes premises and proof, it affects the authors credibility and may negatively impact perception of the site.
A lot of what is posted here is simply opinion, and that includes your opinion as posted above. I didn't disguise anything; I simply stated my opinion. I lack the time or the inclination to find scientific premises and proof for everything that I believe; instead, I consider the source. And in this case, I think the source that I linked to is reputable, and I chose to believe it. Can I prove it beyond a reasonable doubt? No. Could it be wrong? Yes, but it could be right.

However, in the interest of full disclosure, I have gone back and edited my post.

And by the way, I didn't say that I believe everything that's posted on the internet, and I resent the insult to my intelligence.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
FWIW I've had a product in production for going on near 5 years now based on the PIC12HV615, same guts as the '12F675 but with a shunt voltage regulator built in to it.

Nothing "finicky" has been noted.

Bob Pease (quoting Milligan's Law) said:
When you are taking data, if you see something funny, Record Amount of Funny.
Zero funny observed, and I have the blank notebook to back up this claim.
 

THE_RB

Joined Feb 11, 2008
5,438
Ditto, a product here using 12F675 too from years ago with all good news.

The "finicky" comment on that webpage is a personal opinion, and seems based on the idea that the internal oscillator "needs calibration" (his words).

But the 12F675 is supplied with the 4MHz calibration constant pre-programmed, so all that is required is to NOT overwrite that constant, and to load it in code which is two ASM instructions.

If I was to fault the 12F675 internal oscillator compared to newer 8pin PICs it would be that the 12F675 internal osc can only do 4MHz, where newer PICs int osc can do 8Mhz or more. Since the 12F675 is fully capable of 20Mhz operation having the internal osc stuck at 4MHz max is a big "flaw". :)
 

Ian Rogers

Joined Dec 12, 2012
1,136
RB said:
If I was to fault the 12F675 internal oscillator compared to newer 8pin PICs it would be that the 12F675 internal osc can only do 4MHz, where newer PICs int osc can do 8Mhz or more. Since the 12F675 is fully capable of 20Mhz operation having the internal osc stuck at 4MHz max is a big "flaw".
I sort of agree!! I use the pic12f675 extensively, But I don't need a precise oscillator... I use it as a quad encoder and the 'finiky' calibration has no bearing on the operation whatsoever!!! There must be quite a few applications that do not need the precision that other chips give... Putting the cal value in isn't a biggy and getting a new cal from PK2 is easy as well...

I'll keep on using it!!
 

Thread Starter

RodneyB

Joined Apr 28, 2012
697
I must firstly thank everyone for the replies and apologise for the schematic I attached, It had serious mistakes which I did not check.

I am trying to basically get a switch to work. I want to push the button and then an LED comes on for 30 seconds.

Where the biggest problem comes in for me is that I am very; very new at this and basically as I am given code I research it and try and teach myself. I would be better off having someone who can explain the code line by line. Often to nervous to ask for fear of annoying people who help on the forum.

Where I was concerned was on my development board because if the code is right and the board is wrong especially if your unsure you never know where to look.

I managed to run some code that made sure that the PIC12F675 runs and the outputs do come on.

But not for the life of me can I get a push button to turn on and LED. I am at my wits end and blank. And cant understand why I cant get a simple thing to work.

A friend has given me the below code, But it may as well be in hieroglyphics as I cant follow it and when I program it into the PIC12F675 nothing happens.

so any help will be a massive help.

Rich (BB code):
 void interrupt ISR(void)    {  
  
  char flicker;  
    
      INTCONbits.T0IF = 0;        // Clear timer IF flag    
     TMR0 = T_CONST;             // Reload timer    
     ticks++;                            // Adjust tick counter    
      flicker = (ticks >> 2);        // Slow flicker rate down    
      GPIO = flicker;    
 }  
    
 void main (void) {    
  
       ANSEL = 0;                // Config as digital IO     
      CMCON = 0x07;            // Config as digital IO     
       GPIO  = 0;                // Start with outputs off     
           
    OPTION_REG = 0x87;        // Pullups disabled, prescaler 1:256     
    INTCON = 0xE0;            // Enable GIE, PEIE, T0IE    
     
 while(1); 
     
 }
 

Thread Starter

RodneyB

Joined Apr 28, 2012
697
  1. I cant see in the code where the individual bits are made inputs or outputs.
  2. The Character flicker I don't understand what it does.
  3. Do I have to define each of the bits and then set them as outputs?
  4. after the while(1); statement the code that follows will be in a loop forever if my understanding is correct.
  5. I think most of my confusion rises from not understanding flicker and the bits not being defined which makes me stumble at this point
 

Ian Rogers

Joined Dec 12, 2012
1,136
There must be more code... The variable "ticks" must be global!!! and there has to be #include<> statements!!

The config bits allow the OSC to be set.. Internal or external... and whether the MCLR is on or off...
 
Top