0% found this document useful (0 votes)
42 views2 pages

Raising Edge Program

The document is a C program for a PIC microcontroller that configures various settings and initializes ports for input/output operations. It includes an interrupt service routine that responds to a specific condition on PORTB, toggling PORTD based on the input value. The program runs in an infinite loop, continuously updating PORTC with the status of OPTION_REG and INTCON registers every second.

Uploaded by

tpgitspotify
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

Raising Edge Program

The document is a C program for a PIC microcontroller that configures various settings and initializes ports for input/output operations. It includes an interrupt service routine that responds to a specific condition on PORTB, toggling PORTD based on the input value. The program runs in an infinite loop, continuously updating PORTC with the status of OPTION_REG and INTCON registers every second.

Uploaded by

tpgitspotify
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// CONFIG

#pragma config FOSC = EXTRC // Oscillator Selection bits (RC oscillator)


#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#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)

// #pragma config statements should precede project file includes.


// Use project enums instead of #define for ON and OFF.

/*
* File: taskprograminterrupt.c
* Author: HAPPY
*
* Created on June 13, 2025, 11:10 PM
*/

#include <xc.h>
#define _XTAL_FREQ 6000000
void init(void);
unsigned value;

void main(void) {
init();
while(1)
{
PORTC=OPTION_REG;
__delay_ms(1000);
PORTC=INTCON;
__delay_ms(1000);
}
}
void init()
{
TRISC=0x00;
PORTC=0x00;
TRISD=0x00;
PORTD=0x00;
TRISB=0x0F;
PORTB=0x00;
INTCON &=0xFD;
OPTION_REG |=0x40; //enable the raising edge interrupt
OPTION_REG |=0x80;//disable the option reg
INTCON |=0x90;
}
void __interrupt() _ISR(void)
{
if(INTCON & 0x02)
{
value=PORTB;
if(value==0x01)
{
PORTD=0xFF;
__delay_ms(2000);
PORTD=0x00;
__delay_ms(1000);
}
}
__delay_ms(3000);
INTCON &=0xFD;
}

You might also like