Kicking the Watchdog using CAN on S12(X)

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

Kicking the Watchdog using CAN on S12(X)

1,202 Views
petertang
Contributor I

Hi All,

 

I am relatively new to working with Freescale chips (and the embbeded world in general), so please bear with me!

I am using CodeWarrior 5.9.0 with Processor Expert 3.04 and working on MC9S12XET256MAA controllers.

This is actually 2 questions in one; but first here is the context:

  • I have a CAN bus between two uC
    • One a "Master", the other a "Slave"
  • Master sends a CAN msg to Slave
  • Slave receives the msg and sends an ack CAN msg.
  • Slave has a Watchdog which is Kicked when the Slave receives the Master's CAN msg.
    • If the Watchdog is not kicked, it will "bark" and cause the Slave to Reset

 

Questions:

  1. How do I know that the Watchdog caused the Reset?
    • I want the Slave to do something different if the Watchdog barks
  2. Is there a way to react to the most recent Rx CAN msg rather than when it is Full?
    • I have set up internal counters to see which msg the Slave reacts to.
    • There is always a count difference of 4 between the Slave and Master. I'm assuming this is due to the Rx buffer...
    • I want the Slave to react to the msg it just received, not an old one.

 

Thanks.

Labels (1)
Tags (3)
0 Kudos
4 Replies

848 Views
kef
Specialist I

S12(X) have 3 different reset vectors, there's dedicated vector for COP watchdog reset.

It's hard to guess what and how did you code, but maybe your acceptance filters are set up to ignore some messages? You should also make sure overrun flag is not set.


0 Kudos

848 Views
petertang
Contributor I

Thank you for the response.

I am aware that the COP has its own Reset vector. However I am interested in making my main application aware of the fact that the last reset was caused by the COP Watchdog. Is there a register/flag of some sort that I could poll for this information?

I have indeed been playing around with the acceptance filters to help me understand how they work. The Master node only sends one msg, which the Slave node's filter is set to. How does this affect the way the CAN Rx interrupt works?

Again please excuse my naivety, but how do I know if the Overrun Flag is set? Does this generate another interrupt which needs to be serviced?

Many of the configurations have been created for me through Processor Expert. I am in the process of trying to understand all the options available to me (there are a lot!).

Further help would be most appreciated.

0 Kudos

848 Views
kef
Specialist I

There are PORF, LVRF and ILAF flags for power on reset, low voltage reset and illeggal address access reset, but there's no flag for COP reset. But you can define your own COP flag variable. It should be not affected by start up routine (as you should know, ANSI C startup routine by default clears all static variables), so pheraps allocate it in NO_INIT segment instead of READ_WRITE segment. Main reset vector and COP reset vector should point to different routines. One routine should set your COP flag, another one should clear your COP flag, then both routines should jump to startup routine.

Message filter makes CAN RX interrupt not generated for filtered out messages. I hope it answers your question about filters and CAN Rx interrupt interaction.

Yes, you can poll OVRIF flag or enable OVRIE interrupt.

Sorry, I'm not using Processor Expert.


848 Views
petertang
Contributor I

I have implemented your suggestion using a NO_INIT segment using the following post (and your response) as a template:

How to know Reset is WatchDog Reset ?

After initial failure, I managed to get the Watchdog reset working with help from a colleague who changed the Reset RC circuit as suggested by the post.

Regarding the CAN implementation, what I want to do is use a CAN interrupt to wake the uC from WAIT mode, but I also want to use the data to send instructions. Any suggestions as to how to achieve this?

0 Kudos