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

Type(1) One Second Task Program

The document contains configuration settings for a microcontroller, including oscillator selection and watchdog timer settings. It includes a main function that toggles PORTC every second and an interrupt service routine that toggles PORTD every 20 interrupts. The initialization function sets up the necessary registers for operation and enables interrupts.

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)
2 views2 pages

Type(1) One Second Task Program

The document contains configuration settings for a microcontroller, including oscillator selection and watchdog timer settings. It includes a main function that toggles PORTC every second and an interrupt service routine that toggles PORTD every 20 interrupts. The initialization function sets up the necessary registers for operation and enables interrupts.

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
You are on page 1/ 2

#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.

#include <xc.h>
#define _XTAL_FREQ 4000000
unsigned char count;
void init(void);
void main(void)
{
init();

while(1)
{
PORTC=~PORTC;
__delay_ms(1000);

}
void init()
{
TRISC=0x00;
PORTC=0x00;
TRISD=0x00;
PORTD=0x00;
INTCON |=(3<<6);
T1CON =0x01;
PIE1 |=0x01;
PIR1 &=~(1<<0);
TMR1=15535;
}
void __interrupt()_isr()
{
if(PIR1 & 0x01)
{
count++;
if (count==20)
{

PORTD=~PORTD;
count=0;

}
TMR1=15535;
PIR1 &=~(1<<0);
}

You might also like