Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

PIC18F24K50 IOCB4-IOCB7 interrupt problem

Status
Not open for further replies.

cllunlu

Member level 4
Joined
Nov 21, 2006
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,900
Hi Everyone,

I have done IOCC1 and IOCC2 pins interrupt with milan.rajnik is edaboard user. Now I have to use IOCRB4-IOCRB7 pins to interrupt. I edited my code similarly, but program doesnt input interrupt routine. IOCRB4-IOCRB7 interrupts are difference IOCRC1 and IOCRC2.

Anyone could help?

Code is:

sbit W1D0 at RB4_bit;
sbit W1D1 at RB5_bit;

sbit W1D0_Direction at TRISB4_bit;
sbit W1D1_Direction at TRISB5_bit;

sbit LED1 at LATA1_bit;
sbit LED2 at LATA2_bit;

sbit LED1_Direction at TRISA1_bit;
sbit LED2_Direction at TRISA2_bit;

#define INPUT 1
#define OUTPUT 0

#define LOW 0
#define HIGH 1

#define ON 1
#define OFF 0

void init()
{
CM1CON0 = 0x00;
CM2CON0 = 0x00;

ANSELA = 0x00;
ANSELB = 0x00;
ANSELC = 0x00;

TRISA = 0xC0;
TRISB = 0x00;
TRISC = 0x00;

PORTA = 0x00;
PORTB = 0x00;
PORTC = 0x00;

LATA = 0x00;
LATB = 0x00;
LATC = 0x00;

W1D0_Direction = INPUT;
W1D1_Direction = INPUT;

LED1_Direction = OUTPUT;
LED2_Direction = OUTPUT;

LED1 = OFF;
LED2 = OFF;

Delay_ms(200);

IOCIE_bit = 1;
PEIE_bit = 1;
GIE_bit = 1;
IOCB4_bit=1;
IOCB5_bit=1;

IOCIF_bit = 0;

Delay_ms(50);
}
void interrupt(void)
{
IOCIE_bit = 0;
PEIE_bit = 0;

if(IOCIF_bit)
{
IOCIF_bit = 0;

if(!RB4_bit)
{
LED1=1;
}
else if(!RB5_bit)
{
LED2=1;
}
}
}

void main()
{
init();

while(1)
{

}

}
 
Last edited:

How are the switches connected. Post your circuit.

Try attached project. It is compiled for internal 4 MHz oscillator.
 

Attachments

  • Switches and LEDs IOC.rar
    28.8 KB · Views: 119

Did my code work ? The difference is TRISB settings.
 

I only checked the button circuit and they are fine. I didn't check the rest.
 

If you have Proteus then draw the circuit in Proteus.

Edit: Soory, there is no PIC18F24K50 in Proteus. It is a new chip. You can try with other chips ?
 

Your demo code doesnt work milan.rajnik.I dont understand where is mistakes
 

The code should work fine. See attached image for switch and Led connections. If switch is connected other way then change code like below.

Code:
if(RB4_bit) { 
     LED1 = ON;
}
else if(RB5_bit) {
     LED2 = ON;
}
 

Attachments

  • conn.png
    conn.png
    18.6 KB · Views: 83

The pins are input and they are always HIGH.(The antenna send 5V always when it doesnt send data. When it sends data, It send logically LOW). Jayanth, if you can see my circuit that links is below, You will realize.
 

I understood but I have never worked with Weigand Protocol (comm). Maybe someone else can help you better.


Something related to Weigand here.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top