How to enable and configure watch dog interrupt in MPC5748G

cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable and configure watch dog interrupt in MPC5748G

Jump to solution
386 Views
FAISAL0323
Contributor I

Hi Experts,

I would like to know how and which register we can configure to enable watchdog interrupt and then write ISR for that. (I am using MPC5748G)

Objective is to save some variables in RAM and send that out through CAN,  before watchdog reset the board. This mechanism, I want to implement that in interrupt ISR of  WATCHDOG. 

I know how to save these variables in RAM and then send them out through CAN but I don't know where and how to write these statements so that I can see certain variables through CAN before watchdog reset my chip.

 

Thanks in advance

Thanks in advance

0 Kudos
1 Solution
304 Views
petervlna
NXP Employee
NXP Employee

Hello,

I would disable the SWT in its ISR. Then I will try to sent out CAN messages.

Once you disable SWT,in ISR, you can simply debug your CAN routine in SWT ISR function.

 

To reset micro is enough do mode transition:

petervlna_0-1645432414213.pngpetervlna_1-1645432426183.png

 

petervlna_2-1645432449339.png

 

petervlna_3-1645432485399.png

 

Hope it helps,

best regards,

Peter

 

 

View solution in original post

0 Kudos
8 Replies
351 Views
petervlna
NXP Employee
NXP Employee

Hello,

Well, to be honest you choose complex micro for learning and it wont be any easy.

But to answer your questions:

As you mentioned in your reply that I need write my specific code in SWT watchdog ISR routine. Since I am beginner , would you please let me know where I can see that ISR routine in NXP project?

ISR routine you have to write by yourself. Its is simple function, which is defined in your ISR vector table amd it is called as soon as the SWT ISR flag is set and interrupts are enabled.

what should be the syntax of writing that ISR function? like void ISR(void){} something like that.

For example here's my PIT ISR:

petervlna_0-1645083100861.png

Does NXP provide any demo project for watchdog with interrupts ?

For watchdog I do not know, but for interrupt , yes. Here are some examples, also with interrupts

https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/MPC5-software-example-list/ta-p/1102445#MPC5748G

Lastly you mentioned about external interrupt (IVOR4). Is it same with SWT ISR routine or it is different?

IVOR4 is external core interrupt. One that comes from INTC module, so it comes from peripherals.

I recommend you to carefully read the INTC chapter in reference manual first, to understand the INTC mechanism and reporting.

Once you understand interrupt structure, the simplest way is to modify the existing example code for SWT interrupt.

You will need to configure:

1. INTC

2. linker for interrupt table (if not done already)

3. SWT

4. write or reuse INTC table where you define your ISR

5. write ISR in your app

All this will be dependent on your workspace and compiler used.

You  can start with going trough Cookbook:

https://www.nxp.com/docs/en/application-note/AN4830.pdf

 

Best regards,

Peter

 

0 Kudos
348 Views
FAISAL0323
Contributor I

Thanks Peter for your help

I have successfully implemented that interrupt feature. I have now last ambiguity which is as follows

Which statement can be used to reset the board when we are in watchdog interrupt ISR?

If we don't write reset statements in ISR and we are assure that ISR compilation time is always less then watchdog timeout. would board be reset automatically after second consecutive timeout without writing reset statements in ISR?

Best Regards 

 

 

0 Kudos
332 Views
petervlna
NXP Employee
NXP Employee

Hello,

Which statement can be used to reset the board when we are in watchdog interrupt ISR?

You can simply do the mode transition into reset mode.

If we don't write reset statements in ISR and we are assure that ISR compilation time is always less then watchdog timeout. would board be reset automatically after second consecutive timeout without writing reset statements in ISR?

Yes, but from safety point of view, I would consider the secound SWT timeout reset reaction as backup to the SW triggered reset in ISR.

But of course this depends on the application requirements from safety standpoint of view.

Best regards,

Peter

0 Kudos
311 Views
FAISAL0323
Contributor I

Thanks Peter for your detailed explanation. I have successfully implemented and then validated watchdog interrupt feature in my code and it works normal. But still there are some ambiguities , if possible , please address them. would be thankful. 

 

In interrupt ISR , I have written code to blink led to make it sure my interrupt ISR is working and it works very well in my  app but our objective as I mentioned earlier is to send certain 8 byte  CAN messages before  reset after two consecutive timeout but in my ISR code  when I replace Led blinking code with CAN messages code, my CAN messages code is not working but reset is successful.  Please be noted our watchdog timeout is 5 seconds and CAN messages code takes 0.1 ms to 0.2 ms to send 8 bytes.

 

I have done following couple of  things to deal with that issue but still no success

1- service the watchdog in ISR

2- write same CAN messages code in other part of APP and it works so we are sure CAN messages code is working normal but does not work in  WATCHDOG ISR

Also if possible, please address, which register I should configure to reset my chip in ISR. You have mentioned earlier I need to change transition mode, would you please address, which register is responsible for that. 

Thanks for your time

Best Regards

 

 

0 Kudos
305 Views
petervlna
NXP Employee
NXP Employee

Hello,

I would disable the SWT in its ISR. Then I will try to sent out CAN messages.

Once you disable SWT,in ISR, you can simply debug your CAN routine in SWT ISR function.

 

To reset micro is enough do mode transition:

petervlna_0-1645432414213.pngpetervlna_1-1645432426183.png

 

petervlna_2-1645432449339.png

 

petervlna_3-1645432485399.png

 

Hope it helps,

best regards,

Peter

 

 

0 Kudos
262 Views
FAISAL0323
Contributor I

Hi Peter,

Thanks for your  guidance. Desired logic has been implemented successfully. 

 

Regards

 

0 Kudos
373 Views
petervlna
NXP Employee
NXP Employee

Hello,

I would like to know how and which register we can configure to enable watchdog interrupt and then write ISR for that.

Reference manual: 52.5.5 Time-out

petervlna_0-1645017887347.png

Objective is to save some variables in RAM and send that out through CAN, before watchdog reset the board. This mechanism, I want to implement that in interrupt ISR of WATCHDOG.

Simply implement it in your SWT ISR routine.

but I don't know where and how to write these statements so that I can see certain variables through CAN before watchdog reset my chip.

I am bit confused here. Once you are in ISR you have one watchdog timeout to perform the actions. Or you can simply disable SWT in ISR and then do reset by SW from ISR. It really depends on application implementation requirements.

What you are trying to achieve should be very simple.

First make sure your device is triggering external interrupt  (IVOR4) for watchdog ISR. Once you have working ISR, you simply add your code and handle next SWT timeout. (if SWT timeout is not long enough for your action then disable or service SWT in that ISR as well)

Best regards,

Peter

0 Kudos
365 Views
FAISAL0323
Contributor I

Thank you Peter for your detailed explanation. From that explanation, I have successfully identified and configured these specific registers.

 

But I did not understand some points which if possible,  please explain further.

As you mentioned  in your reply that I need write my specific code in SWT watchdog ISR routine. Since I am beginner , would you please let me know where I can see that ISR routine in NXP project? what should be the syntax of writing that ISR function? like void ISR(void){} something like that.

 

Does NXP provide any demo project for watchdog with interrupts ?

 

Lastly you mentioned about external interrupt  (IVOR4). Is it same with SWT ISR routine or it is different?

 

Ones again thank you so much for your time.

Regards

 

 

 

 

0 Kudos