S32K146 CAN wake up

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

S32K146 CAN wake up

2,585 Views
hajianik
Senior Contributor I

Hi,

I'm trying to wake up from VLPS mode from several different sources which include CAN.

I CAN GO TO SLEEP(VLPS) AND WAKE UP VIA ALL THE DIFFERENT SOURCES USING THEIR CORRESPONDING PIN INTERRUPTS EXCEPT FOR CAN.

Here is my strategy to wake up through CAN:

I go to sleep on absence of CAN traffic for certain amount of time 

CONFIGURING  CAN0_RX PIN(PTE4) AS FALLING EDGE PIN INTERRUPT .

PTE4 PIN INTERRUPT IS ENABLED RIGHT BEFORE I GO TO SLEEP,  AND DISABLED JUST AFTER WAKE UP.

The issue is when I kill the CAN TRAFFIC via CAN ALYZER I EXPECT CAN0_RX TURNS IDEAL(HI) AND WHEN I START CAN , I WOULD SEE A FALLING EDGE ON PTE4 AND THE PIN INTERRUPT WOULD BE ASSERTED.

But what actually happens is that as soon as PTE4 pin interrupt is enabled it is triggered (WITHOUT CAN TRAFFIC)

and this prevents me to go to sleep.

I know I need to scope this but was wondering if there is something about PTE4 that I don't know.

Thanks

Tags (1)
0 Kudos
9 Replies

1,839 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Do you put the FlexCAN module into Freeze Mode?

It is better to disable the module before VLPS.

Then disable the FIRC, SOSC, PLL clocks.

Configure the edge wakeup, you can use Digital filter on that pin clocked by LPO in VLPS.

Thanks,

Daniel

0 Kudos

1,839 Views
hajianik
Senior Contributor I

Hi Daniel,

There is a self reception bit in MCR register which I disabled and it still shows activity on CAN_RX pin.

as I said I identify the source of this the message that I transmit at the initialization phase to arm the TX interrupt.

So it seems to me that disabling the self reception should've taken care of it.

Is this similar to loop back mode?

Anyways I disabled the message buffer in question before I go to sleep and enable it when I wake up

and it SEEMS to work. I've to do more testing to confidently say that.

0 Kudos

1,839 Views
hajianik
Senior Contributor I

Daniel,

Thanks for your reply,

Disabling CAN before entering  VLPS crossed my mind.

What about disabling the particular message buffer that keeps sending that message.

My biggest question is though.

If the loop back mode is not enabled and the transceiver is in sleep mode why there is activity on CAN0_RX?

Thanks,

0 Kudos

1,839 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Koorosh,

The Freeze mode is required because the FlexCan cannot directly enter Stop mode / Disable Mode.

In Freeze mode, no transmission or reception of frames is done and synchronicity to the CAN bus is lost.

You wrote that the FlexCAN is resending the not acknowledged message. So, what you see is expected because the on-board tranceiver reads the diferential analog signal and returns it on the Rx pin.

Regards,

Daniel

1,839 Views
hajianik
Senior Contributor I

Hi Daniel,

O.K transceiver is causing this , It makes sense.

Indirectly related to this is what I stated earlier . For me to be able to transmit  from within the ISR:

I need to call FLEXCAN0_transmit_msg() once in the init phase otherwise it will never hit FLEXCAN0_transmit_msg() inside the ISR.

Is that because it comes out as full and once we transmit it becomes available?

void CAN0_ORed_0_15_MB_IRQHandler(void)

{

can_timeout_flg=0;

if ((CAN0->IFLAG1 >> 4) & 1) { /* If CAN 0 MB 4 flag is set (received msg), read MB4 */

FLEXCAN0_receive_msg ();

}

if((CAN0->IFLAG1 & 1)){

FLEXCAN0_transmit_msg();

}

Please note that the interrupt flags are cleared in FLEXCAN0_receive_msg() and FLEXCAN0_transmit_msg()

functions

0 Kudos

1,839 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Koorosh,

I have difficulties to understand. What is the problem now?

Without ACK, it will keep resending it automatically. You can abort it though.

Anyway, in this case, the trasmission is not completed succesfully so the flag IFLAG1_BUF4TO1I is not set.

Or you want to stop calling the transmit function before VLPS? If so, then place a condition in that ISR.

BR, Daniel

0 Kudos

1,839 Views
danielmartynek
NXP TechSupport
NXP TechSupport

HI,

I would definitely measure the pin.

Do you reconfigure the pin to GPIO?

As you probably know, you can leave it as CAN0_RX.

You can test it with the simple code below. It triggers only if falling edge is detected.

You could enable the digital filter on that pin.

Regards,

Daniel

#include "S32K146.h" /* include peripheral declarations S32K146 */

void PORTE_IRQHandler(void)
{
    if(PORTE->PCR[4] & (1 << 24))
    {
        PORTE->PCR[4] |= (1 << 24); // Clear the flag
    }
}

int main(void)
{
    // PTE
    S32_NVIC->ICPR[1] = (1 << (63 % 32));
    S32_NVIC->ISER[1] = (1 << (63 % 32));
    S32_NVIC->IP[63] = 0x00;  // Priority level 0

    PCC-> PCCn[PCC_PORTE_INDEX] = PCC_PCCn_CGC_MASK; // Enable clock to PortE - BUS_CLK
    PORTE->PCR[4] = 0x000A0500;
    // [19–16] 19–16 = 1010 ISF flag and Interrupt on falling-edge
    // [10-8] MUX = 0b101 CAN0_RX

    while(1);

    /* to avoid the warning message for GHS and IAR: statement is unreachable*/
#if defined (__ghs__)
#pragma ghs nowarning 111
#endif
#if defined (__ICCARM__)
#pragma diag_suppress=Pe111
#endif
    return 0;
}
0 Kudos

1,839 Views
hajianik
Senior Contributor I

I believe I found the issue however not sure how to solve it .

to arm the  CAN0_ORed_0_15_MB_IRQHandler  for TX I had to send a CAN message once so that this interrupt would be triggered for my subsequent  transmit messages which are sent in ISR.

Doing that causes the CAN0_RX keeps transitioning . I would say this message sent by the CAN controller is received back even though it is not acked by the other node , so the controller keeps sending that and it keep showing on the CAN_RX. In other word it is receiving its own transmit message , so as soon as I enable the interrupt for this pin before I go to sleep the pin interrupt is asserted and keeps me from going to sleep.

At least this is my theory.

The Question is how do I prevent this? can I use hardware filter for IDs?

not sure how to do that.

Thanks,

Koorosh 

0 Kudos

1,839 Views
hajianik
Senior Contributor I

Hi Daniel,

Thanks for your reply.

I did  both. I left the pin PTE4 as CAN_RX and configured  for falling edge interrupt  and also reconfigured it as GPIO and back to CAN_RX. Either way behavior is the same .

I scoped it and I noticed there are transitions on CAN_RX even when I stop CANALYZER and pull the CAN CABLE.

SOMETIMES IT WORK (WHEN THERE ARE NOT TRANSITIONS)AND I CAN WAKE IT UP WITH ANY CAN MESSAGE.

I need to understand where those transition on CAN_RX come from .

The only entity that send any CAN message should be CANALYZER and that is off.

Lastly I tried to enable the passive filtering to this pin and Processor expert do not let me.

Is pin filtering available for a pin configured as CAN_RX? 

0 Kudos