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 CCS Technical Support

Latch register for i/o ports

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



Joined: 06 Jul 2006
Posts: 1
Location: UK

View user's profile Send private message

Latch register for i/o ports
PostPosted: Sat Sep 27, 2008 11:25 am     Reply with quote

Am using PCWH 4.079.
Target is PIC18F252.
Is it possible to read the i/o port latch registers, rather than the pins themselves, using C syntax?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 27, 2008 11:59 am     Reply with quote

There is no CCS function to read the latch registers. But you can use
a #byte statement to declare the register addresses, and then read
them directly, in code. Example:
Code:
#include <18F452.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)

#byte LATA = 0xF89
#byte LATB = 0xF8A
#byte LATC = 0xF8B
#byte LATD = 0xF8C
#byte LATE = 0xF8D

//=====================================
void main()
{
int8 value;

value = LATC;  // Read the latch register for Port C

while(1);
}



The register addresses come from this section of the PIC data sheet:
Quote:
TABLE 4-1: SPECIAL FUNCTION REGISTER MAP
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