Watchdog for MCF52235 - Cannot turn it on

cancel
Showing results for 
Search instead for 
Did you mean: 

Watchdog for MCF52235 - Cannot turn it on

1,456 Views
paynete
Contributor I
Working with ColdFire_Lite Tcp Stack.  Having an issue with unresponsive TCP or general lockup.  Thought I would enable watchdog.
 
Changed mcf5223_wtm_init in mcf5223_sysinit.c to turn on Watchdog.
void mcf5223_wtm_init(void)
{
 /*
 * Enable Software Watchdog Timer - Timing 2^23 * Bus Freq
 */
 MCF_SCM_CWCR =  MCF_SCM_CWCR_CWT(5)  |
     MCF_SCM_CWCR_CWE  |
     MCF_SCM_CWCR_CWTA  |
     MCF_SCM_CWCR_CWTAVAL |
     MCF_SCM_CWCR_CWTIC  ;
           
 MCF_INTC0_ICR8  =  MCF_INTC_ICR_IL(2);     
 MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK8);
  
 MCF_SCM_CWSR = 0x55;
 MCF_SCM_CWSR = 0xAA;
}
 
Tried without setting    CWTA,  CWTAVAL,  & CWTIC  also.
 
Added _watchdog_handler to mcf5223_vectors.s as .extern and to vector48:
 .extern _watchdog_handler
vector48: .long  _watchdog_handler //_irq_handler
 
Added  watchdog_handler to Int_handlers.c to perform soft reset
__interrupt__
void watchdog_handler (void)
{
  mcf5xxx_irq_disable();
 MCF_CIM_RCR |= MCF_CIM_RCR_SOFTRST;  //TEP Software Reset *********************** 
}
 
Purposely did not service the CWSR on a periodic basis for test.
 
What am I doing wrong.
 
Labels (1)
0 Kudos
1 Reply

190 Views
paynete
Contributor I
Solved my own issue.  I've not had much luck with receiving help from this forum in a timely manner :smileysad:.  In case this helps someone else, here is what works for me.
 
This is the init from mcf5223_sysinit.c
 
void
mcf5223_wtm_init(void)
{
 //
 // Enable Software Watchdog Timer - Timing 2^23 * Bus Freq
 //
 // WatchDog Service Routine
 MCF_SCM_CWSR = 0x55;
 MCF_SCM_CWSR = 0xAA;
 // Set Watchdog Timing Delay
 // 6 = 2^27 * Bus Clock Frequency (60MHz) = 2.23 Seconds
 MCF_SCM_CWCR =  MCF_SCM_CWCR_CWT(6);
 // Enable Watchdog
 MCF_SCM_CWCR |= MCF_SCM_CWCR_CWE;
 // WatchDog Service Routine
 MCF_SCM_CWSR = 0x55;
 MCF_SCM_CWSR = 0xAA;
 // Wait to Hook ISR
 
Moved the ISR Hook to the init function of a FreeRTOS task for the project which executes much later:

 //Hook Watchdog ISR to Interrupt
 MCF_INTC0_ICR8  =  MCF_INTC_ICR_IP(7) | MCF_INTC_ICR_IL(3);
 MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK8);
 Csa_watchdog_is_ready = 1;
 
Serviced the Watchdog by waking a task after 1 sec within the system clock ISR:
 
__declspec(interrupt)
void
timer_isr()
{
  ++timer_ticks;
  if (++timerct >= INTS_PER_CTICK)
  {
     cticks++;
     if (Csa_watchdog_is_ready)
     {
       if(!(--Csa_wdog_timer_cnt))
       {
           Csa_wdog_timer_cnt = CSA_WDOG_CNT;
         CsaProcessList |= CSA_WATCHDOG_PROCESS;
       TK_WAKE(&to_csa);
       }
     }
 
The Task that services the ISR:
void csa_watchdog_process(void)
{
 MCF_SCM_CWSR = 0x55;
 MCF_SCM_CWSR = 0xAA;
 //printf("watchdog ");
 CsaProcessList &= ~CSA_WATCHDOG_PROCESS;
}
0 Kudos