Disabling MSCAN signals

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Disabling MSCAN signals

1,226 Views
dps_hound
Contributor I

I am currently  trying to optimize the sleep mode in my battery application.  I have attempted to disable all GPIO signals and other HC12 subsystems in order to reduce current consumption during sleep.  The MSCAN, however, has given me some problems.  I have been trying to reduce the CANtx and CANrx signal levels to zero by disabling MSCAN altogether before putting the processor into STOP mode.  I then use the respective port M bits as GPIO and set them to output low.  I do this with the following code (or variations of it):

 

 

        CAN0CTL0 &= ~(BIT2);                         // Disable wakeup from sleep
        CAN0CTL0 |= (BIT1);                             // Enter sleep mode in order to disable CAN
        CAN0CTL0 |= (BIT0);                             // Enter init mode in order to disable CAN
        while ((CAN0CTL1 & BIT1)==0)
        {
            RefreshCopModule();                        
            Delay(1000);
        }
        CAN0CTL1 &= ~(BIT7);                            // Disable CAN
        DDRM.Byte |= (BIT1|BIT0);
        PORTM.Byte &= ~(BIT1|BIT0);
        .
        .
        // Put processor into STOP mode
       CLKSEL.Bits.PSTP = 0;
       Clear_CCR_S();
       while (true)
       {
           _asm("stop");
       }
When I reset and run my target with my BDM emulator (PE Micro) I get the results I expect.  In particular, the CANtx and CANrx signals are low.  Strangely, when I power cycle my target with the same code and let it run without emulator control, these same signals do NOT go low:
CANtx ~ 4v
CANrx ~ 3.75v
This consequently causes much high power consumption on my target board.
I have tried other configuration scenarios with the CAN including:
1) Don't do anything to it before putting processor into STOP mode.
2) Putting MSCAN only into SLEEP mode before stopping the processor.
None of these have given me the desired results.
Any help would be much appreciated!
Wil
Labels (1)
0 Kudos
Reply
5 Replies

714 Views
kef
Specialist I

CANE is write once bit. You can't turn it off in normal mode. It is possible only in special modes (debugger by default uses special single chip mode).

Did you wire your chip directly to CAN bus? In normal systems there's CAN driver between MCU and the BUS. Disabling MSCAN won't drop bus levels to zero.

0 Kudos
Reply

714 Views
dps_hound
Contributor I

Thx kef for your prompt response to my issue.

 

I was aware of the restrictions on writing CANE and had indeed put the processor into special single chip mode beforehand.   However, I am not sure there are any restrictions on putting the HC12 into this mode, after it has already been in normal single chip mode.

 

On your other question, our CAN lines from the MCU go directly into an isolator chip, just before going to a CAN transceiver.  As for the CAN signal from the MCU, I have noticed that in certain circumstances (when operating in debug mode through our BDM debugger) the MCU signals go right down to zero but in other circumstances (when not reset by our deugger) the CAN signals float between 3.5-4.0 volts.  The first outcome is what I want, since the sleep current of our target drops towards what we want.

0 Kudos
Reply

714 Views
kef
Specialist I

In special single chip mode CPU is stopped out of reset. This is useful for debugging, since you can debug from the start of your application; but it is not useful for real life applications. After reset (booting) into special single chip mode, to make target running you need to send GO command via BDM interface...

I think you should either extend your circuit to make MCU driving some FET, that would switch on/off current to optocoupler emitters, or maybe consider isolated transceiver like ISO1050.

 

BTW this is a 8-bitters forum. S12 is 16-bits. Please use right forum next time.

0 Kudos
Reply

714 Views
dps_hound
Contributor I

It was my intention to enter special single chip mode only for the purpose of bringing down the CAN, prior to putting my MCU into stop mode.  However, I am not sure this is allowed but the documentation does not obviously forbid it.  Once in stop mode, we only wakeup again by resetting the MCU, which puts it back into normal single chip.

 

On your point about FETs, upon shutting down the MCU CAN, we subsequently shutdown power to the opto-coupler chip as well.  This, in turn, zeros any stray CAN signal levels getting onto the CAN bus.  This is desired.  However, what I am struggling to understand is why the MCU CAN signals can, in one scenario, have a non-zero output and in another, have zero signal level when I disable MSCAN.

0 Kudos
Reply

714 Views
kef
Specialist I

Transition from normal to special modes is not possible. To enter SS mode, you pull BKGD/MODC pin low and reset.

 

Could you show MSCAN part of your circuit diagram?

0 Kudos
Reply