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

PCH FSR access

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







PCH FSR access
PostPosted: Thu Dec 26, 2002 1:53 pm     Reply with quote

How can I define the FSR names to the memory location in PCH. In PCM I would create a #Byte statement with the memory address of the FSR in question. This method doesn't seem to work for PCH though.

Paul
___________________________
This message was ported from CCS's old forum
Original Post ID: 10263
Kurt Franke
Guest







Re: PCH FSR access
PostPosted: Thu Dec 26, 2002 5:57 pm     Reply with quote

Paul,

Well, I don't understand why it should do this, but the compiler clears the high FSR when you write to the low one..

Example:

.................... FSR0H = 0x01;
0012: MOVLW 01
0014: MOVWF FEA
.................... FSR0L = 0xFF;
0016: CLRF FEA <--- Huh???
0018: MOVLW FF
001A: MOVWF FE9
....................

So... just write your values to the low FSR first, then the
high one.

This program works:

#include <18f452.h>
#byte FSR0L = 0xFE9
#byte FSR0H = 0xFEA
#byte INDF0 = 0xFEF

void main ()
{
FSR0L = 0xFF;
FSR0H = 0x01;

INDF0 = 0xAA; // writes 0xAA to 0x1FF
}

good luck,
Kurt


:=How can I define the FSR names to the memory location in PCH. In PCM I would create a #Byte statement with the memory address of the FSR in question. This method doesn't seem to work for PCH though.
:=
:=Paul
___________________________
This message was ported from CCS's old forum
Original Post ID: 10264
Tomi
Guest







Re: PCH FSR access
PostPosted: Fri Dec 27, 2002 5:36 am     Reply with quote

There is a small confuse in CCS C about byte/word registers.
This works for me:
#byte FSR0 = 0xFE9
........
FSR0 = 0x1234;
The list:
.................... FSR0 = 0x1234;
0342: MOVLW 12
0344: MOVWF FSR0H
0346: MOVLW 34
0348: MOVWF FSR0L

As you can see FSR0 is defined as a single byte but a write attempt handles it as a 16-bit word Smile
I think this is true for Timer registers, etc. (16-bit hardware registers)


:=How can I define the FSR names to the memory location in PCH. In PCM I would create a #Byte statement with the memory address of the FSR in question. This method doesn't seem to work for PCH though.
:=
:=Paul
___________________________
This message was ported from CCS's old forum
Original Post ID: 10270
Mark



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

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

Re: PCH FSR access
PostPosted: Fri Dec 27, 2002 9:21 am     Reply with quote

In that case, CCS will probably change it and it will no longer work in the future. Why not do it this way?

long FSR0;
#locate FSR0 = 0xFE9

FSR0 = 0x1234;

Regards,
Mark

:=There is a small confuse in CCS C about byte/word registers.
:=This works for me:
:=#byte FSR0 = 0xFE9
:=........
:=FSR0 = 0x1234;
:= The list:
:=.................... FSR0 = 0x1234;
:=0342: MOVLW 12
:=0344: MOVWF FSR0H
:=0346: MOVLW 34
:=0348: MOVWF FSR0L
:=
:=As you can see FSR0 is defined as a single byte but a write attempt handles it as a 16-bit word <img src="http://www.ccsinfo.com/pix/forum/smile.gif" border="0">
:=I think this is true for Timer registers, etc. (16-bit hardware registers)
:=
:=
:=:=How can I define the FSR names to the memory location in PCH. In PCM I would create a #Byte statement with the memory address of the FSR in question. This method doesn't seem to work for PCH though.
:=:=
:=:=Paul
___________________________
This message was ported from CCS's old forum
Original Post ID: 10271
Paul Kleissler
Guest







Re: PCH FSR access
PostPosted: Fri Dec 27, 2002 2:55 pm     Reply with quote

Great Ideas I will give them a try.

Paul

:=In that case, CCS will probably change it and it will no longer work in the future. Why not do it this way?
:=
:=long FSR0;
:=#locate FSR0 = 0xFE9
:=
:=FSR0 = 0x1234;
:=
:=Regards,
:=Mark
:=
:=:=There is a small confuse in CCS C about byte/word registers.
:=:=This works for me:
:=:=#byte FSR0 = 0xFE9
:=:=........
:=:=FSR0 = 0x1234;
:=:= The list:
:=:=.................... FSR0 = 0x1234;
:=:=0342: MOVLW 12
:=:=0344: MOVWF FSR0H
:=:=0346: MOVLW 34
:=:=0348: MOVWF FSR0L
:=:=
:=:=As you can see FSR0 is defined as a single byte but a write attempt handles it as a 16-bit word <img src="http://www.ccsinfo.com/pix/forum/smile.gif" border="0">
:=:=I think this is true for Timer registers, etc. (16-bit hardware registers)
:=:=
:=:=
:=:=:=How can I define the FSR names to the memory location in PCH. In PCM I would create a #Byte statement with the memory address of the FSR in question. This method doesn't seem to work for PCH though.
:=:=:=
:=:=:=Paul
___________________________
This message was ported from CCS's old forum
Original Post ID: 10274
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