View previous topic :: View next topic |
Author |
Message |
jguarin2002
Joined: 11 Nov 2007 Posts: 5
|
can_set_mode problem in can18fxx8.c driver. |
Posted: Wed Dec 05, 2007 2:48 pm |
|
|
The set_can_mode function goes like this:
Code: |
void can_set_mode(CAN_OP_MODE mode){
CANCON.reqop=mode;
while( (CANSTAT.opmode) != mode );
}
|
Sometimes, when I call set_can_mode (CAN_OP_CONFIG); the function freezes, I guess the while expression inside the function remains true no matter if the CANCON.reqop=mode instruction its been executed. The CANSTAT reg should change but it doesn't.
So what it is happening?
regards
P.D. pic18f258 + ccs compiler 3.232 _________________ Julián Andrés Guarín |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 05, 2007 3:11 pm |
|
|
I've never heard of this bug, but here is a post where they say to
put it in Loopback mode before going to Config mode.
http://osdir.com/ml/hardware.bus.can/2003-11/msg00003.html
In other words, he is saying to do this:
Code: |
can_set_mode(CAN_OP_LOOPBACK);
can_set_mode(CAN_OP_CONFIG);
|
|
|
|
jguarin2002
Joined: 11 Nov 2007 Posts: 5
|
|
Posted: Wed Dec 05, 2007 7:57 pm |
|
|
Yes but Im trying to go from normal op to config op. Besides Im usign 18f258 that issues a built-in can module no need for 2515 can host.
So it is different that topic. But thanks anyway.
What its very sad is that this was not happening at all (same code for 2 week worked ok, and after that, without making any change it suddenly does not work anymore). The problem with this is that I cant set filters any more... (well one among the the rest).
Could anyone please try to figure it out, what's going on?. Is there a built in problem with this MCUs? Its incredible strange... i try to compile other porgrams that use the filtering feature amd they did not workl! again the op_config_mode part!!!!!! Help!.
When I do
CANCON|=80; REQOP2 is in 1 thus requesting config mode.
CANSTAT should be in 80 confirming the config state. But it never changes!.
Help please! Anyone! _________________ Julián Andrés Guarín |
|
|
|