PIC I/O Pins have problem on RESET....

Status
Not open for further replies.
I have PIC 18f452 with PICC ide and compiler. I have strange behavior of pins that is on master reset if i set their TRIS=0 and put the PIN on Low status. on startup it turns ON one time then behaves like i programmed.
pin output is attached with an external counter(for example) it deforms the results.
Is there any program/code setting that it should'nt turn ON on first startup.
Best Regards,
Joe.
 
Are you setting the port to 0 before setting tris to 0?

If for example your code is like:
TRISA = 0;
PORTA = 0;

Then, when you start your pic, you'll have an unknown output, however if you change the order to:
PORTA = 0;
TRISA = 0;

Then it should start up properly.
 
Hi MP,

Check the data sheet page 91, it shows the PORT values on POR.

When you turn the micro on and set the PORT as an output, it is configured as an output with the stated output i-e -1111111. Where as if you will read them on power up than you will get all -x0x0000.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…