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

HS mode 20Mhz, irregular values when reading/writing to regi

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







HS mode 20Mhz, irregular values when reading/writing to regi
PostPosted: Thu Dec 05, 2002 12:58 pm     Reply with quote

When using 18F258 with 20Mhz crystal and HS mode (No PLL) I cannot write to register without putting a delay between writes.

Example:

#byte CANCON = 0xf6f
#byte RXM1EIDL = 0xf1f
#byte RXM1EIDH = 0xf1e
#byte RXM1SIDL = 0xf1d
#byte RXM1SIDH = 0xf1c
#byte RXM0EIDL = 0xf1b
#byte RXM0EIDH = 0xf1a
#byte RXM0SIDL = 0xf19
#byte RXM0SIDH = 0xf18


void main( void ) {

CANCON = 0x80; //Set configuration mode
RXM0SIDH = xx; // write any values to registers
RXM0SIDL = yy;

printf( "\%2x, \%2x\r", RXM0SIDH,RXMOSIDL );
CANCON = 0x00; // return to normal mode

The printf command will not return xx and yy but a fixed other value.
if I insert a delay_ms(1) (1ms has no relevance, could be less, don't know exactly how much less...) between each of the register writes the code will return the correct values.

The above is just a code extraction, the real code is much bigger but the effect is the same. A short delay between writes makes it all work.

Can anyone enlighten me to why it acts like this ????
( PCWH 3.128 )

Best wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 9807
trean
Guest







Re: HS mode 20Mhz, irregular values when reading/writing to
PostPosted: Thu Dec 05, 2002 3:10 pm     Reply with quote

Oh well...

I respone to myself I must admit to not reading the datasheet closely enough.

After changing operation mode you must monitor the opmode bits before accessing the registers.

I did not delete my originalpost since I thought that this may be of help to someone in the future when they search this board.
(Which I do alot...)
___________________________
This message was ported from CCS's old forum
Original Post ID: 9810
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