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

Is it possible to read a constante as high and low byte?

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







Is it possible to read a constante as high and low byte?
PostPosted: Tue Nov 12, 2002 12:11 pm     Reply with quote

Does anyone know if it is possible to read a
constant as high and low byte, something like this:

#define COUNT 0x10FF

#asm
movlw HIGH COUNT
movwf TMR0H
movlw LOW COUNT
movwf TMR0L
#endasm

-Ivar
___________________________
This message was ported from CCS's old forum
Original Post ID: 8808
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Is it possible to read a constante as high and low byte?
PostPosted: Tue Nov 12, 2002 12:31 pm     Reply with quote

:=Does anyone know if it is possible to read a
:=constant as high and low byte, something like this:
:=
:=#define COUNT 0x10FF
:=
:=#asm
:= movlw HIGH COUNT
:= movwf TMR0H
:= movlw LOW COUNT
:= movwf TMR0L
:=#endasm
:=
:=-Ivar

This may be what you are looking for.

set_timer0(COUNT);
___________________________
This message was ported from CCS's old forum
Original Post ID: 8810
Ivar Johnsrud
Guest







Re: Is it possible to read a constante as high and low byte?
PostPosted: Tue Nov 12, 2002 12:33 pm     Reply with quote

:=:=Does anyone know if it is possible to read a
:=:=constant as high and low byte, something like this:
:=:=
:=:=#define COUNT 0x10FF
:=:=
:=:=#asm
:=:= movlw HIGH COUNT
:=:= movwf TMR0H
:=:= movlw LOW COUNT
:=:= movwf TMR0L
:=:=#endasm
:=:=
:=:=-Ivar
:=
:=This may be what you are looking for.
:=
:=set_timer0(COUNT);
:=

Yeah, I just realized, thanks.

-Ivar
___________________________
This message was ported from CCS's old forum
Original Post ID: 8812
Sherpa Doug
Guest







Also check out MAKE8()
PostPosted: Tue Nov 12, 2002 12:50 pm     Reply with quote


___________________________
This message was ported from CCS's old forum
Original Post ID: 8813
johnpcunningham
Guest







Re: Is it possible to read a constante as high and low byte?
PostPosted: Tue Nov 12, 2002 1:31 pm     Reply with quote

<font face="Courier New" size=-1>Another idea for you (like a UNION) using 16F877:

//register locations
#byte TMR1L 0x0E
#byte TMR1H 0x0F

void main(){
int16 timer1_long;

//get 16 bit value of timer
timer1_long = make16(TMR1H, TMR1L);

//set timer values
TMR1L = 0xAA;
TMR1H = 0xBB;

while(1){};
}</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 8814
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Is it possible to read a constante as high and low byte?
PostPosted: Tue Nov 12, 2002 3:05 pm     Reply with quote

Yet another way....

using 16F877:

long TMR1;
#locate TMR1 = 0x0E

#define TIMERVALUE 0xAA55
void main(void)
{
TMR1 = TIMERVALUE;
while(1)
{
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 8816
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