CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

What is the difference between a latch and a port register ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
newbie222
Guest







What is the difference between a latch and a port register ?
PostPosted: Wed Nov 05, 2008 9:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 05, 2008 12:54 pm     Reply with quote

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.
newbie22
Guest







PostPosted: Wed Nov 05, 2008 1:31 pm     Reply with quote

sorry i will put it in the other thread

newbie22
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group