View previous topic :: View next topic |
Author |
Message |
Paul Kleissler Guest
|
PCH FSR access |
Posted: Thu Dec 26, 2002 1:53 pm |
|
|
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 |
Posted: Thu Dec 26, 2002 5:57 pm |
|
|
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 |
Posted: Fri Dec 27, 2002 5:36 am |
|
|
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
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
|
Re: PCH FSR access |
Posted: Fri Dec 27, 2002 9:21 am |
|
|
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 |
Posted: Fri Dec 27, 2002 2:55 pm |
|
|
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 |
|
|
|