|
|
View previous topic :: View next topic |
Author |
Message |
Torello
Joined: 29 Sep 2006 Posts: 120
|
CAN Disable Mode, PIN_B3 current issue: >resolved. |
Posted: Thu Nov 06, 2008 4:50 am |
|
|
Hello,
I don't want to use the CAN-module of my 18Lf4685, I just need Pin_B3. According to datasheet the CAN-module needs to be put in Disable mode. At power-up it is in Conf.Mode.
Issue 2 (not the worst) is that PIN_B3 needs to be put output high to get the CAN module to acknowledge Disable mode. With output low it will wait endlessly. As an input it waits to pickup hum or whatever.
Question: I want to unconditionally force the CAN to be disabled. Any thoughts?
Issue 3 (YAK!): although CAN-module disabled, low level on B3 draws an extra current of 0.3mA (@Vdd=3V)! One could think there is an internal pullup of about 10k. But after putting B3 high again the current remains !! I need to give out a new Disable mode command to the CAN module, and then the current is back on it's old value. Very strange..
Does anybody know how to really disable the CAN mode? Hopefully "Yes we CAN" .... or ...?
Regards,
Edwin
Code: |
#include <18F4685.h>
#fuses INTRC_IO, NOFCMEN, IESO, PUT
#fuses NOBROWNOUT, NOWDT, NOPBADEN, LPT1OSC
#fuses MCLR, STVREN, NOLVP //CCS_ICD uses NOLVP!
#use standard_io(A)
#use standard_io(B)
#use standard_io(C)
#use standard_io(D)
#use standard_io(E)
#use delay(clock=4000000)
#use RS232(stream=debug, Baud=9600, Bits=8, Xmit=PIN_B6, Rcv=PIN_B7, DISABLE_INTS)
#byte CANCON = 0xF6F
#byte CANSTAT = 0xF6E
#byte OSCTUNE = 0xf9b
#Byte CIOCON = 0xF73
#Byte PIR3 = 0xFA4
#Bit ABAT = CANCON.4
#bit INTSRC = OSCTUNE.7
void main() {
setup_oscillator(OSC_INTRC | OSC_4MHZ);
INTSRC=1;
output_high(PIN_B3); //default Can Module is in Conf. mode. Pin B3 needs to high
//in oder to get the CAN module to disable mode
fprintf(debug, "<Anykey>: Start test program\n");
fgetc(debug);
do {
fprintf(debug,"%x\n",Canstat);
delay_ms(100);
CanCon = 0x20;
} While ((CanStat&0xE0)!=0x20); //wait for the CAN module to acknowledge Disable mode
fprintf(debug, "CAN in Disable Mode\n");
// Mcu now draws 1.35 mA
fgetc(debug);
fprintf(debug, "B3 low\n");
output_low(Pin_b3); //make B3 low
delay_ms(200);
fprintf(debug,"%x\n",Canstat); //still reports Disable mode
// Mcu now draws 1.65 mA
fgetc(debug);
fprintf(debug, "B3 high\n"); //make B3 high again
output_high(Pin_b3);
// Mcu still draws 1.62 mA
fgetc(debug);
CanCon = 0x20;
While ( (CanStat&0xE0)!=0x20); //wait for the CAN module to acknowledge Disable mode
fprintf(debug, "CAN in Disable Mode\n");
// Mcu is back to 1.35mA
fgetc(debug);
fprintf(debug, "Switching to 31Khz\n");
setup_oscillator(OSC_INTRC | OSC_31KHZ); //switch to 31Khz internal
INTSRC=0;
#use delay(clock=31250)
CanCon = 0x20;
While ( (CanStat&0xE0)!=0x20); //wait for the CAN module to acknowledge Disable mode
while (1) { //no B3 current issue here;
//running on 31khz the current issue is not there
output_high(Pin_b3); //high/low both 53uA (3volt)
delay_ms(100);
output_low(Pin_b3);
delay_ms(100);
}
}
|
Last edited by Torello on Fri Nov 07, 2008 2:25 am; edited 2 times in total |
|
|
Torello
Joined: 29 Sep 2006 Posts: 120
|
|
Posted: Thu Nov 06, 2008 5:53 am |
|
|
YAK even more....
The extra Vdd current seems to be frequency depending.
-At Fosc=500Khz /Vdd=3v the extra current is 0.14mA
-At Fosc=8Mhz /Vdd=3v the extra current is 0.45mA
Strange.. |
|
|
Ttelmah Guest
|
|
Posted: Thu Nov 06, 2008 6:16 am |
|
|
Try turning off the detection of bus states.
This is still enabled with the module disabled, and might well draw some current.
Best Wishes |
|
|
Torello
Joined: 29 Sep 2006 Posts: 120
|
|
Posted: Thu Nov 06, 2008 7:13 am |
|
|
Hi Ttelmah,
If you can drop me a code snippet how to, I would be delighted!
Thanks,
Edwin. |
|
|
Ttelmah Guest
|
|
Posted: Thu Nov 06, 2008 8:28 am |
|
|
WAKDIS=1
ENDRHI=0
Best Wishes |
|
|
Torello
Joined: 29 Sep 2006 Posts: 120
|
|
Posted: Fri Nov 07, 2008 2:23 am |
|
|
Hi Ttelmah,
Many thanks!! It works! Setting WAKDIS=1 does the trick.
Best regards,
Edwin
Last edited by Torello on Mon Nov 10, 2008 2:03 pm; edited 1 time in total |
|
|
Ttelmah Guest
|
|
Posted: Fri Nov 07, 2008 3:53 am |
|
|
Yes. I wasn't sure 'which' might be the culprit. Glad it worked. :-)
Best Wishes |
|
|
Torello
Joined: 29 Sep 2006 Posts: 120
|
|
Posted: Fri Nov 07, 2008 4:18 am |
|
|
I didn't try both combinations, but definitely WAKDIS needs to be 1.
Strange that it is default on and that they forget to mention to put off for real normal B3 behavior/functionality.
But anyway, many thanks.
Best Wishes,
Edwin. |
|
|
Ttelmah Guest
|
|
Posted: Fri Nov 07, 2008 2:54 pm |
|
|
It is mentioned in the data sheet.
The reason is that you can use this to allow you to put the CAN bus circuitry to sleep, and then when the bus changes state, turn the circuitry back on.
Best Wishes |
|
|
|
|
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
|