What is the difference between a latch and a port register ?
Posted: Wed Nov 05, 2008 9:55 am
hey
Can someone tell me the difference between latch and port please, and what output_high() works with port or latch....
Reason is this:
Code:
#include<18F45K20.h>
#fuses H4
#use delay(clock=64000000)
void main()
{
output_low(PIN_B4) // connected to LED low is switched off
delay_ms(5000);
output_high(PIN_B4) // connected to LED high is switched on
while(1);
}
In the above program once the pic is turned on there is an 5 sec delay then led comes on and stays on. What happens is: if we do a mclr reset (ie. ground mclr)
1- PIC resets itself and goes to initialization state
- In this state PORTB goes to uuu0 0000 state:
please note:(u) stands for unchanged.
- latch goes to uuuu uuuu (all latch is unchanged)
2-the processor resets go back to the beginning of the code
- LED SHOULD BE SWICTHED OFF AS PORTB4 is 0
My question: I am seeing that my LED is still on when I do an mclr reset. why. (If the code is reset then LED will only turn on after 5 secs due to initialization state).
Also if what should happen according to the data sheet PIC18F45K20.
Please help because I am losing it.
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Wed Nov 05, 2008 12:54 pm
Don't start a new thread when you already have an existing thread on
your port-reset problem:
http://www.ccsinfo.com/forum/viewtopic.php?t=36631
Add any new questions as a post on that existing thread. When you do
so, the thread will go to the top of the list. Everyone will see it.
Members of the forum that are logged in will see a yellow mark on the
left side (you don't see it as a guest) that shows a new post has been
made.
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