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.

Quik Question: Simple microprocessor problem

Status
Not open for further replies.

Iawia

Member
Does anyone know if there is some sort of precaution using GP2?
I can not set it high EVER. I have two brand new pic-12F508 microprocessors.
It builds fine, I load it onto the chip from a pickit 2, then put 5v to my breadboard and nothing happens. If I change the code to set all the other pins high (except GP3 bc its always input).

The code is trivial.

Code:
#include <htc.h>

__CONFIG(MCLRE_OFF & CP_OFF & WDT_OFF & OSC_IntRC);

void main(){

	TRIS = 0b111011;							// GP2 is the only output
	GPIO = 0b000100;							// Setting GP2 HIGH

	for(;;)										// Loop forever
	{	;	}
}

I have tried compiling it in xc.h and htc.h with no luck. I got the code directly from Microchip's tutorials. Pg. 11., except that I change the GPIO and TRIS with respect to GP2 instead of GP1.

I'm all out of ideas.
 
Last edited:
Look up the OPTION register explanation in the data sheet, as on reset the TOCKI is enabled and overides the TRIS register. Clear the TOCS bit in code and you will be good to go.
 
nickelflippr,

I confess, I had my doubts about your suggestion bc the tutorial never spoke about this. But I tried it today anyways, and it is now settable. I suppose it was never mentioned bc that particular bit wasn't being used for anything in the tutorial. You are a sage. Thanks bunches my friend.

-t
 
Hi Iawia,
if you look to the attached Pinout from the datasheet, you can see beside the GP number, each pin has another function to do if the microcontroller is set for that in your code. For instance, GP2 / T0SCI.
 
Yes I am aware there are other options, however, what I did not know is that some default to 'GP' while other pins default to the option. For instance, pin 5 defaults to T0sci, while pins 2, 3, 6, 7 default to GP it seems. Not sure why the inconsistency, but I'm super happy I can move forward to the next phase of the design.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top