Hi
Been struggeling a bit, and can't get my interrupts to work,
PIC16F690
Code is running, but Interrupt not triggered.
. will say when i put something in interrupts routine, the code is executed allways,( Dont know if this is the meaning to do ? )
Been struggeling a bit, and can't get my interrupts to work,
PIC16F690
Code:
#include <htc.h>
#include <stdio.h>
#include <stdlib.h>
#include "lcd.h"
#include <string.h>
// CONFIG
#pragma config FOSC = INTRCIO // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Selection bits (BOR enabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is disabled)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)
#ifndef _XTAL_FREQ
// Unless specified elsewhere, 8MHz system frequency is assumed
#define _XTAL_FREQ 8000000
#endif
#define KN1 RC5
#define KN2 RC4
#define KN3 RC6
#define KN4 RC7
#define back_light RA2
unsigned int run_to_sec,sekund;
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
static void interrupt isr(void) // Here is interrupt function - the name is unimportant.
{
if (T0IF) // timer 0 overflow
{
T0IF=0;
run_to_sec++;
if (run_to_sec==200)
{run_to_sec=0;
sekund=1;
}
}
}
void setup(void)
{
IRCF0=1; // 8 mhz
IRCF1=1;
IRCF2=1;
SCS=1; // internel clock
OSTS=0;
// setup timer 0 to run on Internal FOSC/4
T0CS=0;
PSA=0;
PS0=1; // Prescale 1:256
PS1=1;
PS2=1;
TRISA0=1;
TRISA1=1;
TRISA2=0;
TRISA3=1;
TRISA4=1;
TRISA5=0;
TRISB4=0; // = out
TRISB5=0;
TRISB6=0;
TRISB7=0;
TRISC0=0; // Out
TRISC1=0;
TRISC2=1; // Other in;
TRISC3=0; // test LED
TRISC4=1;
TRISC5=1;
TRISC6=1;
TRISC7=1; // rc7 in.
ANSEL=0; // all digital.
ANSELH=0;
}
void main(void) {
setup();
lcd_init();
lcd_goto(0);
lcd_puts("Hello");
RC3=0;
GIE=1; // Global interrupt
T0IE=1;
T0IF=0;
back_light=0;
while (1)
. will say when i put something in interrupts routine, the code is executed allways,( Dont know if this is the meaning to do ? )