hello,
I have a problem with the interruption of PORTB .
interrupt does not work.
I put the 4.7K resistor to VSS. could you help me understand my mistakes.
main.c
Code:
/*
* File: main.c
* Author: christop.soguel
*
* Created on 6. novembre 2014, 10:49
*/
/** C O N F I G U R A T I O N B I T S ******************************/
#pragma config WDTE = ON, PWRTE = OFF, CP = OFF, BOREN = ON, FCMEN = ON, MCLRE = ON, CPD = OFF, IESO = ON, FOSC = INTRCCLK
#include <stdio.h>
#include <stdlib.h>
#include <pic16f690.h>
#include <xc.h>
#define CAPTEUR1 PORTAbits.RA3
void Debounce (void);
unsigned int CompteurA = 0; // Counter variable for debounce routine.
unsigned int CompteurB = 0; // Counter variable for debounce routine.
unsigned int CompteurI= 0; // Counter variable for debounce routine.
void interrupt ISR (void)
{
if (INTCONbits.RABIF)
{
Debounce();
INTCONbits.RABIF = 0;
return;
}
}
void main (void)
{
OSCCON= 0b01100101; //Freq = 4MHZ
OSCTUNE=0b00000000;
TRISC = 0b00000000;
TRISB = 0b01110000;
TRISA = 0b00000000;
IOCB = 0b01110000; // enable the top 3 IOC interrupts on PORTB
PORTC = 0b00000000;
OPTION_REGbits.nRABPU =0;
OPTION_REGbits.INTEDG = 1;
INTCONbits.GIE = 1; // Global Interrupt Enable
INTCONbits.RABIE = 1; // enable interrupt on change (IOC) for ports A & B
INTCONbits.RABIF = 0;
unsigned int uiCpt;
unsigned char iCompteur;
unsigned int i;
unsigned char iSeconde;
unsigned char TEST1=1;
do
{
PORTC = 0b00000110;
if (CompteurA >= 10)
{
PORTC = 0b00000111;
}
}while (TEST1==0);
}
void Debounce (void)
{
if (!RB4 )
{
CompteurA = CompteurA + 1;
}
if (!RB5)
{
CompteurB = CompteurB + 1;
}
if(!RB6)
{
CompteurI = CompteurI + 1;
}
}
/* for (iCompteur = 0; iCompteur < 1; iCompteur ++ )
{
for( i=0;i<1000;i++)
{
// Met le driver moteur en Mode CW
PORTC = 0b00000110;
}
}
for (iSeconde = 0; iSeconde < 15; iSeconde ++)
{
for ( uiCpt = 0; uiCpt < 10000 ;uiCpt ++)
{
// Met le driver moteur en Mode BRAKE
PORTC = 0b00000111;
}
}CAPTEUR1 == 1
TEST1=0;*/