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

READ CONFIG BYTES on 18F252 ?

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







READ CONFIG BYTES on 18F252 ?
PostPosted: Tue May 20, 2003 7:01 am     Reply with quote

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 ?
PostPosted: Tue May 20, 2003 7:33 am     Reply with quote

:=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 ?
PostPosted: Tue May 20, 2003 8:07 am     Reply with quote

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
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