|
|
View previous topic :: View next topic |
Author |
Message |
trean Guest
|
HS mode 20Mhz, irregular values when reading/writing to regi |
Posted: Thu Dec 05, 2002 12:58 pm |
|
|
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 |
Posted: Thu Dec 05, 2002 3:10 pm |
|
|
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 |
|
|
|
|
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
|