MC9S12DP512 CAN1 Pin access

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

MC9S12DP512 CAN1 Pin access

Jump to solution
1,099 Views
HarryHirn
Contributor I

hi

 

i figured out a strange behaviour of my program.

when i am within the debugger or just flashed my controller, everything works.

if i hit reset or power it up again and run it without the debugger it behaves not as within the debugger.

 

i managed to identify the problem:

 

my program initializes all components at the beginning, also the can1 is initialized and enabled (through bean) and i can send around messages etc.

 

now i wrote a function to manually toggle the can txd pin to generate a wake pattern as i want it to look like.

 

 

void FTCAN_generate_wake(void){  CAN1CTL0_INITRQ = 1;          // Get into configuration mode  CAN1CTL1_INITAK = 1;          // to be able to disable CAN1.  CAN1CTL1_CANE = 0;            // Disable CAN1 to take manual control of pin TXD                                                                               DDRM_DDRM3 = 1;               // Set pin TXD as output    PTM_PTM3 = 1;                 // Start of wake pattern generation  FUNCTIONS_delay(100);  PTM_PTM3 = 0;  FUNCTIONS_delay(100);  PTM_PTM3 = 1;  FUNCTIONS_delay(100);  PTM_PTM3 = 0;  FUNCTIONS_delay(100);    CAN1CTL1_CANE = 1;            // Reenable CAN1 and    CAN1CTL1_INITAK = 0;          // close configuration mode.  CAN1CTL0_INITRQ = 0;  FUNCTIONS_delay(10);  CAN1RIER = 127;               // Reenable the CAN1 interrupts. Can only be set when not in configuration mode.}

 

 

when i am in the debugger these waveforms appear on the scope.

when i hit reset and run it without the debugger it happens nothing.

 

reading the mscan2 manual i found a sentence telling me:

"Write: Anytime when INITRQ = 1 and INITAK = 1, except CANE which is write once in normal and
anytime in special system operation modes when the MSCAN is in initialization mode (INITRQ = 1 and
INITAK = 1)."

 

does this mean that i am not able to enable and disable CANE in normal mode after initialization?

then it would be strange if the debugger let my program do this

 

how can i gain access to txd on can1 in another way without setting my controller to a special operation mode?

Labels (1)
0 Kudos
1 Solution
462 Views
kef
Specialist I
  • reading the mscan2 manual i found a sentence telling me:
  • "Write: Anytime when INITRQ = 1 and INITAK = 1, except CANE which is write once in normal and
    anytime in special system operation modes when the MSCAN is in initialization mode (INITRQ = 1 and
    INITAK = 1)."

 

  • does this mean that i am not able to enable and disable CANE in normal mode after initialization? then it would be strange if the debugger let my program do this

 

Yes, you can't switch CANE off. It is not strange debugger allows to switch CANE off, debugger usually operates chip in special single chip mode.

 

 

  • how can i gain access to txd on can1 in another way without setting my controller to a special operation mode?

You can't operate MCU in special mode without debugger connected to BKGD pin. Manipulating CAN pins sounds like violating CAN protocol. You should not distrurb whole CAN network!

View solution in original post

0 Kudos
3 Replies
463 Views
kef
Specialist I
  • reading the mscan2 manual i found a sentence telling me:
  • "Write: Anytime when INITRQ = 1 and INITAK = 1, except CANE which is write once in normal and
    anytime in special system operation modes when the MSCAN is in initialization mode (INITRQ = 1 and
    INITAK = 1)."

 

  • does this mean that i am not able to enable and disable CANE in normal mode after initialization? then it would be strange if the debugger let my program do this

 

Yes, you can't switch CANE off. It is not strange debugger allows to switch CANE off, debugger usually operates chip in special single chip mode.

 

 

  • how can i gain access to txd on can1 in another way without setting my controller to a special operation mode?

You can't operate MCU in special mode without debugger connected to BKGD pin. Manipulating CAN pins sounds like violating CAN protocol. You should not distrurb whole CAN network!

0 Kudos
462 Views
HarryHirn
Contributor I

hi

 

thanks fpr your reply.

i had the same thing in mind.

 

but for me its still a strange debugger behaviour to allow certain code to be executed which wount run at all in final application. thats not really the idea of debugging and development i have in mind. for me the program i write and debug has to have the identical behaviour in my final application.

 

my manipulation on txd pin should only create a condition to wake transceivers like the one i saw in a datasheet.

didnt thought of manipulating network transactions.

 

nevertheless i think i misunderstood the datasheet...

0 Kudos
462 Views
Lundin
Senior Contributor IV

It has nothing to do with the debugger at all, the various strange (and mainly pointless) modes of the S12 is the culprit. In "special mode" you can disable CANE, and when CAN is disabled, Port M may be used for general purpose I/O. But as long as CAN is enabled, you cannot use port M (unless you map the CAN peripheral to a different port).

 

However, there is never a reason to disable the CAN module. If you want to save power, you should fiddle around with stop and wait modes. Alternatively, if you must use I/O on port M together with CAN, you could try using MODRR in runtime. I wouldn't recommend it.

0 Kudos