problem with sleep mode

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

problem with sleep mode

3,880 Views
deepakchandra
Contributor III

Dear sir ,

We are working with s12zvl32 controller ,in this we are required sleep mode (power saving mode or stop command )from LIN frame and wake up from LIN as well as

With API (periodical interrupt ). As I have attached code in this mail. In this code I have implemented API, watchdog and stop mode .

1.       When my code first time run if there is no LIN command it goes to sleep .after that it will wake up from LIN – working fine

2.       It is working fine with API alone .it will wake up and goes to sleep ok  .

 

PROBLEM:

1.Now when I have send the wake up command from LIN it will wake up and next time before going to sleep it goes reset the controller   and then goes to sleep .

2.After removing watch dog it does not goes to sleep mode after wake up  and reset the controller sometime .

 

I don’t know why it is going to reset ,please suggest me is there any problem with stack ,clock,vector table  ,or any other register setting .

Original Attachment has been moved to: GPA_new1.rar

Labels (1)
0 Kudos
Reply
6 Replies

3,021 Views
RadekS
NXP Employee
NXP Employee

Hi deepak,

I suppose that your command CPMUCOP=0; should disable watchdog. Right?

Unfortunately, this is possible only in special single chip mode. The CPMUCOP register could be written just once in normal mode.

Also modifying CSAD, COPOSCSEL0 and COPOSCSEL1 bits in CPMUCLKS register is possible in normal mode only until we write into the CPMUCOP register.

So, watchdog should be initialized just once in code. Disabling COP doesn’t have sense. If you do not want periodically wake-up just for trigger watchdog, please configure watchdog clock source to some clock which will be disabled during stop mode.

The command “setReg8(CPMURFLG, 0x00U);            /* Clear COP reset flag */” will not clear COP reset flag.

There should be: setReg8(CPMURFLG, 0x08U);            /* Clear COP reset flag */

I would like to recommend disabling edge interrupt inside SCI interrupt routine instead in main().

Note (slightly out of this topic): Be aware, when you combine API and LIN wake-up. When the voltage level on LIN pin is currently low and MCU wakeups by API, LIN PHY will wakeups also and it transfer LIN pin status to SCI module. Therefore, SCI edge interrupt will be triggered also, despite on fact that LIN wake-up signal was not sent yet or duration of LIN wake-up signal is shorter than tWUFR. See chapter 17.4.3.4 Standby Mode with Wake-Up Feature in RM.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

3,021 Views
deepakchandra
Contributor III

Dear sir ,

Thanks for your reply /support .

Sir I have try as per your feedback but it is still reset the controller .

1.I have disable the API and watchdog but we get still problem some time it will reset the controller or does not wake up with LIN .if u have any application note/ reference code for LIN slave wake up and sleep please provide us .

Because in my project we have to used watchdog ,API ,SLEEP mode /stop mode.

2. second in assign frame ID range in this when we are doing request it is giving response as per LIN spec 2.1 but I have confusion when I have request with change

PID it does not giving any response .

Request -3C 06 06 b7 00 24 1f ff ff

Response- 3d 06 01 F7 ff ff ff ff ff –ok now new PID is 24 ,when we request with PID 24 it has to give response – I am right

Now request with PID=24 – no response

*is there any application to write in main or it will change the PID automatically by LIN stack.

Please suggest me how to test this LIN frame id range after positive response .

0 Kudos
Reply

3,021 Views
RadekS
NXP Employee
NXP Employee

Hi Deepak,

  1. That is strange. If I understood correctly, MCU sometime reset or MCU does not wake up with LIN when API and watchdog are disabled and you just use LIN stack and power save mode. Correct?

Did you implement handlers for all interrupts? There might be any unexpected interrupt which causes such strange behavior.

Please look at my example code here:

https://community.freescale.com/docs/DOC-330312

After wake-up even you should clear RXEDGIF flag (directly inside ISR), use command lin_lld_tx_wake_up(); (typically in application code) for wakeup and disable edge interrupt (typically directly inside ISR) by clearing RXEDGIE bit.

  1. I am not sure, if I understood what you want to do. You want change diagnostic class PIDs (0x3C, 0x3D) to 0x24? Unfortunately, this is not possible according LIN specification.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

3,021 Views
deepakchandra
Contributor III

Dear sir,

I will check for sleep mode and get back to u.

About my second question , iam not changing the PID 0x3d or 3c ,I want to Assign PID for frame which I have defined in my LDF

for example .

In my LDF I have defined the frame(actuator1) =0x21, master frame 0x1f,(actuator2)=0x22,

Now I have to use Assign frame ID range LIN command to change PID 0x21 to 0x24 (or other PID)

I have send the command as per LIN spec 2.1 ,and I get the positive response form LIN signal.

Now after that my doubt arise, when I have send the request for actuator1 with new PID 24 (previously 21) I cannot get response from PID 24 – is this correct way to check

Or I have to write any code in my main program to save this PID .

I don’t know what is the correct way to check this please suggest .

0 Kudos
Reply

3,021 Views
RadekS
NXP Employee
NXP Employee

Thank you for clarification.

I went trough the LIN stack code and I see that assign frame id range should be implemented directly by code in CALLBACK_HANDLER inside SCI ISR routine.

lin_lld_sci_rx_isr () - CALLBACK_HANDLER - lin_pid_response_callback_handler() - lin_update_rx() - lin_update_rx_diag_frame () - lin_tl_handler()-lin_process_pdu() - lin_tl_attach_service() - lin_diagservice_assign_frame_id_range()

Did you try already provided example code?

https://community.freescale.com/thread/386007#comment-618725

It works on your side, or not?

In example code I see periodical execution of this code:

if(diag_get_flag(DIAGSRV_READ_DATA_BY_IDENTIFIER_ORDER)){

  l_u16 req_len = 0;

  l_u8 req_data[10];

diag_clear_flag(DIAGSRV_READ_DATA_BY_IDENTIFIER_ORDER);

  /* Process data */

ld_receive_message(&req_len, req_data);

  req_data[0] += 0x40;

  /* Send response */

  ld_send_message(10, req_data);

  }

It is similar to slave_task() code in other Diagnostic demo codes, but more simplified.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

3,021 Views
deepakchandra
Contributor III

Dear sir ,

In Assign frame Id range "lin_cfg.c" it is defined as l_u8 lin_configuration_RAM[LIN_SIZE_OF_CFG]= {0x00, 0x22, 0x1F, 0x3C, 0x3D ,0xFF};ok

now we want to assign frame id range I have to send the command 3c 06 06 b7 00 28 1f ff ff to change the PID 22 to 28 (is it ok).

After sending command we get positive response as below .getting positive response mean that it has change the PID 22 to 28 .

Now I have to send the command 28 instead of 22 to get response ,but on requesting with 28 we cannot get any response .

As per privious mail I think this code is already implemented in LIN stack function as below

void lin_diagservice_assign_frame_id_range()

in my main function I have only read the flag

if(diag_get_flag(DIAGSRV_ASSIGN_FRAME_ID_RANGE_ORDER))

diag_clear_flag(DIAGSRV_ASSIGN_FRAME_ID_RANGE_ORDER);

Is this correct way of testing the assign frame id range is iam right.

0 Kudos
Reply