CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Watchdog timer on PIC24F

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Vern Hardingham



Joined: 27 Jan 2017
Posts: 3
Location: Canada

View user's profile Send private message

Watchdog timer on PIC24F
PostPosted: Fri Jan 27, 2017 2:32 pm     Reply with quote

I have:
Code:
#fuses WPOSTS4, NOWINDIS, NOWDT, ICSP1, NODEBUG, NOWRT, NOPROTECT, NOJTAG
#fuses HS, DISUVREG, NOIOL1WAY, OSCI0, NOCKSFSM, PR, PLL3, NOIESO
#use delay(crystal =12M, clock=32M, USB_FULL)

setup_wdt(WDT_512MS);
while(TRUE)
{
   restart_wdt();
   delay_us(1);
}

When I compile and run, the processor just keeps resetting.

Can someone help me with this?
Ttelmah



Joined: 11 Mar 2010
Posts: 19477

View user's profile Send private message

PostPosted: Fri Jan 27, 2017 3:08 pm     Reply with quote

Some more basic info needed:

What actual processor?.
What compiler version?.
Show the basic 'main' containing the code.
Vern Hardingham



Joined: 27 Jan 2017
Posts: 3
Location: Canada

View user's profile Send private message

PostPosted: Fri Jan 27, 2017 5:01 pm     Reply with quote

The processor is PIC24FJ256GB106

Compiler is CCS PCD IDE v 5.067

Code:
void main()
{
   extern GeneratorStates curState;
                                                     
   initialize();
   GATE = OFF;
   TXKEY = OFF;
   PWRCTL = ON;
   init_SPI();
   ad9833Reset();
   init_UART();
   displayInit();               
   displayClear();
   delay_ms(1);//without delay here first line does not indent properly
   displayCurOff();
   displayStartup();
   delay_ms(144);
   usbstate = USB_INST;
                               
                                 
   TRISC = 0b10010000;
   CS_DAC = 1;                               
   CS_MEM = 1;           
                                                    
   SPI_SCK = 1;                                                                   
   delay_ms(1000); // hold startup screen for 1 second
   displayClrLn(3);
   displaySetcurpos(3, 4);                                                     
   printf(displayWrite, "Calibrating");
   DACcal();
   DACunbufsetlvl2(0x00);
   reset_FLASH();
   unlock_FLASH();
   displaySetcurpos(3, 4);
   beep(100);
   pwrTmr = PWRTIMEOUT;             
   SECONDS_TMR = ON;
   curState = GEN_STARTUP_DISPLAY;   
   
// Enable Watchdog timer here

   setup_wdt(WDT_512MS);                                                               
                                                                        
   while (TRUE)                 
   {                                                       

   // Reset the watchdog timer here
      restart_wdt();
      delay_us(1);
//      StateMachine_Update();
   }                                   
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 27, 2017 5:32 pm     Reply with quote

Also, are you running this with an ICD in Debug mode ?
jeremiah



Joined: 20 Jul 2010
Posts: 1342

View user's profile Send private message

PostPosted: Fri Jan 27, 2017 9:03 pm     Reply with quote

Replace #FUSES NOWINDIS with #FUSES WINDIS

Otherwise, just about every time you call the WDT reset, you will reset the PIC. NOWINDIS enables windowed mode for the WDT. You normally don't want that.


Last edited by jeremiah on Sat Jan 28, 2017 9:25 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19477

View user's profile Send private message

PostPosted: Sat Jan 28, 2017 1:42 am     Reply with quote

As a comment:

TRISC = 0b10010000;

You are aware that the registers on a PIC24, are 16bit wide, not 8bit?.
Vern Hardingham



Joined: 27 Jan 2017
Posts: 3
Location: Canada

View user's profile Send private message

PostPosted: Mon Jan 30, 2017 11:50 am     Reply with quote

Thanks Jeremiah, changing to WINDIS got it working. I guess I was thinking that NOWINDIS meant no windowing but actually means no windowing disable whereas WINDIS means disable windowing.

Also thanks Ttelmah, I'll look into the TRISC. I guess I must only be using the low 8 bits otherwise this would cause problems. Where I want to access just 8 bits of TRISB I have defined TRISBH and TRISBL as the 8 bit portions of the register.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group