romel_emperado
Advanced Member level 2
- Joined
- Jul 23, 2009
- Messages
- 606
- Helped
- 45
- Reputation
- 132
- Reaction score
- 65
- Trophy points
- 1,318
- Location
- philippines
- Activity points
- 6,061
void interrupt timer0()
{
if(T0IF == 1)
{
T0IF = 0;
count++;
if(count == 15)
{
RA2 ^= 1; //toggle LED
count = 0;
}
}
PEIE = 0; // Disables all peripheral interrupts
}
Im also puzzled by my actual PIC hardware. it is very sensitive in power interruption.. unlike in my 8051 it works well even I intend to interrupt the power.. my power supply is regulated..
even when I clear the MCLR pin of my pic it will not reset and stop working after the power interruption.... the power interruption i am mentioning is when I turn and off the switch of my power source.
Sir,
TIMER0 interrupt is working in
my hardware (PIC16F877A)even if i set PEIE=0. Why this is happening?
Note: Interrupt flag bits are set when an interrupt
condition occurs regardless of the state of its
corresponding enable bit or the global
enable bit, GIE (INTCON<7>). User software
should ensure the appropriate interrupt flag
bits are clear prior to enabling an interrupt.
Yes i disabled the flag in ISR. But my problem is, timer0 interrupt is not depending on the PEIE , it occures even if PEIE=0.
Correct. The Peripheral Interrupt Enable bit (PEIE) does not enable/disable TMR0 interrupts. However, the TMR0 Overflow Interrupt Enable bit (TMR0IE) in the INTCON Register does enable/disable TMR0 interrupts.
Is this a PIC circuit you've
construct yourself? Or is it a
development board? If it is one
you put together yourself,
ensure you have a 100nF/.1µF
capacitor across the Vdd and Vss as close to the PIC as
possible, this alleviates some of
the "sensitivity" you spoke of .
Also make sure you have a pull-
up resistor, 10KΩ, attached to MCLR pin,
#include <htc.h>
__CONFIG(WDTE_OFF & HS & ....... & BOREN_OFF)
#ifndef _HTC_H_
#warning Header file pic16f628.h included directly. Use #include <htc.h> instead.
#endif
/* header file for the MICROCHIP PIC microcontroller
* 16F628
*/
#ifndef __PIC16F628_H
#define __PIC16F628_H
//
// Configuration mask definitions
//
// Config Register: CONFIG
#define CONFIG 0x2007
// Oscillator Selection bits
// ER oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, Resistor on RA7/OSC1/CLKIN
#define FOSC_ERCLK 0xFFFF
// ER oscillator: I/O function on RA6/OSC2/CLKOUT pin, Resistor on RA7/OSC1/CLKIN
#define FOSC_ERIO 0xFFFE
// INTRC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
#define FOSC_INTOSCCLK 0xFFFD
// INTRC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
#define FOSC_INTOSCIO 0xFFFC
// EC: I/O function on RA6/OSC2/CLKOUT pin, CLKIN on RA7/OSC1/CLKIN
#define FOSC_ECIO 0xFFEF
// HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN
#define FOSC_HS 0xFFEE
// XT oscillator: Crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN
#define FOSC_XT 0xFFED
// LP oscillator: Low-power crystal on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN
#define FOSC_LP 0xFFEC
// Watchdog Timer Enable bit
// WDT enabled
#define WDTE_ON 0xFFFF
// WDT disabled
#define WDTE_OFF 0xFFFB
// Power-up Timer Enable bit
// PWRT disabled
#define PWRTE_OFF 0xFFFF
// PWRT enabled
#define PWRTE_ON 0xFFF7
// RA5/MCLR pin function select
// RA5/MCLR pin function is MCLR
#define MCLRE_ON 0xFFFF
// RA5/MCLR pin function is digital input, MCLR internally tied to VDD
#define MCLRE_OFF 0xFFDF
// Brown-out Reset Enable bit
// BOD Reset enabled
#define BOREN_ON 0xFFFF
// BOD Reset disabled
#define BOREN_OFF 0xFFBF
// Low-Voltage Programming Enable bit
// RB4/PGM pin has PGM function, low-voltage programming enabled
...
...
...
...
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?