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 CCS Technical Support

CAN Disable Mode, PIN_B3 current issue: >resolved.

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



Joined: 29 Sep 2006
Posts: 120

View user's profile Send private message

CAN Disable Mode, PIN_B3 current issue: >resolved.
PostPosted: Thu Nov 06, 2008 4:50 am     Reply with quote

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 ...? Wink

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

View user's profile Send private message

PostPosted: Thu Nov 06, 2008 5:53 am     Reply with quote

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







PostPosted: Thu Nov 06, 2008 6:16 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Nov 06, 2008 7:13 am     Reply with quote

Hi Ttelmah,

If you can drop me a code snippet how to, I would be delighted!

Thanks,
Edwin.
Ttelmah
Guest







PostPosted: Thu Nov 06, 2008 8:28 am     Reply with quote

WAKDIS=1
ENDRHI=0

Best Wishes
Torello



Joined: 29 Sep 2006
Posts: 120

View user's profile Send private message

PostPosted: Fri Nov 07, 2008 2:23 am     Reply with quote

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







PostPosted: Fri Nov 07, 2008 3:53 am     Reply with quote

Yes. I wasn't sure 'which' might be the culprit. Glad it worked. :-)

Best Wishes
Torello



Joined: 29 Sep 2006
Posts: 120

View user's profile Send private message

PostPosted: Fri Nov 07, 2008 4:18 am     Reply with quote

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







PostPosted: Fri Nov 07, 2008 2:54 pm     Reply with quote

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