Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[SOLVED] Problem with using watchdog timer

Status
Not open for further replies.

Kubilay

Newbie level 4
Joined
Jun 11, 2015
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
42
I'm using loops to check if button is 1 or 0. this process has to continue all time. but watchdog resets evrey 2 seconds. how can i deal with ? hıow can i disable it? or any otter suggestion
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
Which Compiler are you using ? If you are using MPLAB then you can set the config bits in IDE which will be easier or you can use the #pragma derective in code and turn OFF WDT. You have to mention which PIC you are using.
 

Kubilay

Newbie level 4
Joined
Jun 11, 2015
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
42
Which Compiler are you using ? If you are using MPLAB then you can set the config bits in IDE which will be easier or you can use the #pragma derective in code and turn OFF WDT. You have to mention which PIC you are using.
I'm using PIC16F84A coding with MPLAB8 IDE
I couldnt modify config bits and turn off wdt
i'm new on this subject this is my third program
can you tell it in detail
thank you
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,273
Trophy points
1,413
Location
Southwest, USA
Activity points
62,488
Although both are valid options, I typically configure the configuration registers in code, rather than use the IDE.

If you are using the HiTech PICC compiler, you can configure the configuration registers in code with something similar to following statement:

Code:
__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON & LVP_OFF & CPD_OFF & DEBUG_OFF);
The bitwise masks, FOSC_HS, WDTE_OFF, etc are specific to the exact model of PIC for which you are coding and are listed in the device specific header file for the device, in your case the pic16f84a.h file located in the include directory of the compiler.

pic18f84a.h
Code:
//
// Configuration mask definitions
//


// Config Register: CONFIG
#define CONFIG               0x2007
// Oscillator Selection bits
// RC oscillator
#define FOSC_EXTRC           0xFFFF
// HS oscillator
#define FOSC_HS              0xFFFE
// XT oscillator
#define FOSC_XT              0xFFFD
// LP oscillator
#define FOSC_LP              0xFFFC
// Watchdog Timer
// WDT enabled
#define WDTE_ON              0xFFFF
// WDT disabled
#define WDTE_OFF             0xFFFB
// Power-up Timer Enable bit
// Power-up Timer is disabled
#define PWRTE_OFF            0xFFFF
// Power-up Timer is enabled
#define PWRTE_ON             0xFFF7
// Code Protection bit
// Code protection disabled
#define CP_OFF               0xFFFF
// All program memory is code protected
#define CP_ON                0xC00F
If you are using the newer XC8 compiler and MPLABX IDE, the configuration register statements are like the following:

Code:
// CONFIG
#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (PWRT enabled)
#pragma config BOREN = ON       // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF        // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF        // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF        // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)
And can be generated and inserted into your code automatically using the Configuration Bits Window within the MPLABX IDE.


BigDog
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
If possible zip and post the complete MPLAB 8 project files.
 

Kubilay

Newbie level 4
Joined
Jun 11, 2015
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
42
here is file attached below.

i want to increase number in sayac when i push the button and see it from leds in binary. led at the left side reflects least significant bit.
thank you milan.rajik for your interest
 

Attachments

Last edited by a moderator:

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,273
Trophy points
1,413
Location
Southwest, USA
Activity points
62,488
It was not clear that you were using Assembly Language to program your device.


Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
;**********************************************************************
;                                                                     *
;   This file is a basic code template for assembly code generation   *
;   on the PIC16F84A. This file contains the basic code               *
;   building blocks to build upon.                                    *
;                                                                     *
;   Refer to the MPASM User's Guide for additional information on     *
;   features of the assembler (Document DS33014).                     *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:        xxx.asm                                         *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:                                                          *
;    Company:                                                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files required: P16F84A.INC                                      *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************
 
 
    list      p=16F84A             ; list directive to define processor
    #include <p16F84a.inc>         ; processor specific variable definitions
 
    __CONFIG   _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
 
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
 
;***** VARIABLE DEFINITIONS
w_temp        EQU     0x0C        ; variable used for context saving 
status_temp   EQU     0x0D        ; variable used for context saving
 
;**********************************************************************
RESET_VECTOR      CODE    0x0000  ; processor reset vector
        goto    start             ; go to beginning of program
 
ISR               CODE    0x0004  ; interrupt vector location
 
Interrupt:
 
        movwf  w_temp             ; save off current W register contents
        movf   STATUS,w           ; move status register into W register
        movwf  status_temp        ; save off contents of STATUS register
 
;  Place ISR Here
 
        movf   status_temp,w      ; retrieve copy of STATUS register
        movwf  STATUS             ; restore pre-isr STATUS register contents
        swapf  w_temp,f
        swapf  w_temp,w           ; restore pre-isr W register contents
        retfie                    ; return from interrupt
 
MAIN_PROGRAM    CODE
 
start:
 
LIST P=PIC16F84A
 
__CONFIG_XT_OSC
 
 
STATUS EQU 0X03
PORTA EQU 0X05
PORTB EQU 0X06
TRISA EQU 0X85
TRISB EQU 0X86
SAYAC EQU 0X0D
TMR0 EQU 0X01
 
BSF STATUS,5
BSF TRISB,0
CLRF TRISA
BCF STATUS,5
 
CLRF SAYAC
CLRF PORTA
 
GENEL
BTFSS PORTB,0
GOTO GENEL
CLRF TMR0
INCF SAYAC,F
MOVF SAYAC,W
MOVWF PORTA
GOTO TEST
 
TEST
BTFSS PORTB,0
GOTO GENEL
GOTO TEST
 
 
 
 
        goto $
 
        END



The proper configuration statement for the MPASM assembler is as follows:

Code:
__CONFIG _FOSC_EXTRC & [COLOR="#FF0000"]_WDTE_OFF[/COLOR] & _PWRTE_OFF & _CP_OFF
The configuration bit mask in RED disables the Watchdog Timer.

Your original code has the oscillator configure as an external RC circuit. Is this correct? Or is the design utilizing an external crystal?

If it is a crystal what is its frequency, 4MHz, 8MHz, etc?


BigDog
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top