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 support@ccsinfo.com

Watchdog timer is not working in 18F26K22
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19469

View user's profile Send private message

PostPosted: Fri Jan 17, 2014 2:33 am     Reply with quote

As I said _without WDT_.
You are meant to be testing whether your chip is actually clocking at 64MHz, _first_. The code you have posted proves nothing about the clock speed, and is a waste of space.

However, add the line:

setup_oscillator(OSC_PLL_ON|OSC_16MHz);

at the start of your main.

On these chips, the PLL, when running with the internal oscillator, is a _software enabled_ option, not a fuse option. Now most modern compilers 'know' this, and will correctly enable it, but some slightly older ones need this line, and it does 'no harm' anyway.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Fri Jan 17, 2014 4:11 am     Reply with quote

Ttelmah wrote:
Seriously, do what PCM programmer said a few posts ago, and step 'back' to a simple flash an LED program. No WDT.

Verify that at each clock rate you are trying to use, with a one second 'flash', the LED does flash at one second intervals.

.............................................

Adding a watchdog, without proper code to control it, is pointless, and won't help your code reliability at all.

Please tell us what your 'blinking rates' are.

To me, you're doing too many tests.
You should not need more than two:-

1) Which does not exercise the WDT.
2) Which does with only one minor change.

Mike

PS You're also confusing me by comparing Test 3 with itself!
Quote:
Test 3 : clock 4Mz, Watchdog timer prescale: 1:1(4ms)
--> LED is blinking well like test 3.but period of blinking is shorter than test 3. Namely led is blinking rapidly.
temtronic



Joined: 01 Jul 2010
Posts: 9208
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jan 17, 2014 6:49 am     Reply with quote

Since the 26k22 is the smaller brother of the 46k22, here's a working 'flashing LED ' program to try.

Code:
//46k22 1Hz LED test program
#include <18f46k22.h>
// #include "46k22_fuses.h"
//46k22 fuses
#fuses H4                  //uses PLL*4 speed
#fuses INTRC_IO               //use internal osc (yes !!)
//#fuses XT                  //4MHz xtal with caps
//#fuses nopllen               //disable PLL (NOT x4 speed !)
#FUSES noMCLR                    //Master Clear pin disabled,pin 1( RE3 available !)
#FUSES NOWDT                     //No Watch Dog Timer
#FUSES WDT128                    //Watch Dog Timer uses 1:128 Postscale
#FUSES NOBROWNOUT                //No brownout reset
#FUSES BORV20                    //Brownout reset at 2.0V
#FUSES PUT                       //Power Up Timer
#FUSES NOLVP                     //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG                   //No Debug mode for ICD
#FUSES NOPROTECT                 //Code not protected from reading
#FUSES NOCPD                     //No EE protection
#FUSES NOWRT                     //Program memory not write protected
#FUSES NOWRTD                    //Data EEPROM not write protected
#FUSES NOWRTB                    //Boot block not write protected
#FUSES NOEBTR                    //Memory not protected from table reads
#FUSES NOEBTRB                   //Boot block not protected from table reads
#FUSES NOCPB                     //No Boot Block code protection
#FUSES NOWRTC                    //configuration not registers write protected
#FUSES NOFCMEN                   //Fail-safe clock monitor enabled
#FUSES NOPBADEN                  //PORTB pins are configured as digital I/O on RESET
#FUSES STVREN                    //Stack full/underflow will cause reset
#FUSES NOIESO                    //Internal External Switch Over mode enabled
#FUSES LPT1OSC                   //Timer1 configured for low-power operation
#FUSES NOXINST                   //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#include "46k22_pins.h"
#use delay(clock=64000000)
#define LED PIN_B3

//************************************
void main() {
while(1) {
delay_ms(500);
output_toggle(LED);
}//***************end of forever while
}//************************end of main


please copy/paste/compile/test and confirm the LED is flashing at a 1Hz rate. I've tested this with a real 4MHz xtal/caps as well as internal osc at both 16 and 64 MHz.

hth
jay
alx



Joined: 29 Jan 2014
Posts: 2
Location: Leon

View user's profile Send private message

18f26k22
PostPosted: Wed Jan 29, 2014 11:46 am     Reply with quote

I have one question.

i have pic c compiler version 4.10 but i can't find the library for the 18f26k22.

anybody know where can i get it or download it?
temtronic



Joined: 01 Jul 2010
Posts: 9208
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jan 29, 2014 2:21 pm     Reply with quote

You'll need to upgrade your compiler !

jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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