|
|
View previous topic :: View next topic |
Author |
Message |
IK1WVQ Guest
|
READ CONFIG BYTES on 18F252 ? |
Posted: Tue May 20, 2003 7:01 am |
|
|
hi,
it is possible to read (write) the values of the CONFIG BYTES
from inside the program (directly "C" or by an assebler rutine)
in a 18F252 ???
thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514588 |
|
|
acid Guest
|
Re: READ CONFIG BYTES on 18F252 ? |
Posted: Tue May 20, 2003 7:33 am |
|
|
:=hi,
:=it is possible to read (write) the values of the CONFIG BYTES
:=from inside the program (directly "C" or by an assebler rutine)
:=in a 18F252 ???
:=
:=thanks
Ti riferisci ai config bit?
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514590 |
|
|
Woody Guest
|
Re: READ CONFIG BYTES on 18F252 ? |
Posted: Tue May 20, 2003 8:07 am |
|
|
Yes. The table read and write feature of the PIC18 must be used. This is described in the data sheet under "special features of the cpu".
Something like the following code snippet or something similar might do.
#include <18f252.h>
#pragma case
typedef union tagAddress {
struct {
int8 byte0;
int8 byte1;
int8 byte2;
} ubyte;
int32 uint32;
} Address;
void config_write (int32 addr, int8 value )
{
#pragma ASM
MOVF ((Address) addr).ubyte.byte0,W
MOVWF 0xFF6
MOVF ((Address) addr).ubyte.byte1,W
MOVWF 0xFF7
MOVF ((Address) addr).ubyte.byte2,W
MOVWF 0xFF8
MOVF value,W
TBLWT*+
#pragma ENDASM
}
int8 config_read (int32 addr )
{
int8 value;
#pragma ASM
MOVF ((Address) addr).ubyte.byte0,W
MOVWF 0xFF6
MOVF ((Address) addr).ubyte.byte1,W
MOVWF 0xFF7
MOVF ((Address) addr).ubyte.byte2,W
MOVWF 0xFF8
TBLRD*
MOVFF 0xFF5,value
#pragma ENDASM
return (value);
}
void main (void)
{
int8 v;
config_write (0x300008, 0x20 );
v = config_read (0x300008 );
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514592 |
|
|
|
|
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
|