#pragma code _RESET_INTERRUPT_VECTOR = 0x000800
void _reset (void)
{
_asm goto _startup _endasm
}
#pragma code
#pragma code _HIGH_INTERRUPT_VECTOR = 0x000808
void _high_ISR (void)
{
_asm goto change _endasm
}
#pragma code _LOW_INTERRUPT_VECTOR = 0x000818
void _low_ISR (void)
{
;
}
#pragma code
void change(void)
{
INTCON3bits.INT1IF = 0;
}
#pragma code high_vector=0x08
void interrupt_at_high_vector(void)
{
_asm GOTO high_isr _endasm
}
#pragma code /* return to the default code section */
#pragma interrupt high_isr
void high_isr(void)
{
INTCON3bits.INT1IF = 0; //CLEAR INT FLAG
}
/** I N C L U D E S **********************************************************/
#include <p18f4550.h>
#include<adc.h>
#include<delays.h>
#include<timers.h>
#include<portb.h>
/** V A R I A B L E S ********************************************************/
#pragma udata
//void change(void);
void high_isr(void);
void initall(void);
void init_LCD4(void);
void OpenLCD(void);
void WriteCmd(unsigned char a);
void WriteChar(unsigned char a);
void WriteString(char* tolcd);
void WriteStringL(char* tolcd,int l);
void WriteInt(int i,int l);
void WriteLong(long i,int l);
void WriteULong(unsigned long i,int l);
void ClearScreen(void);
void ResetCursor(void);
void MoveToDisplay(unsigned char a);
void ShiftDisplayRight(int i);
void ShiftDisplayLeft(int i);
void LCDinit(void);
void Delay_s(int i);
void Delay_ms(int i);
void Delay_us(int i);
/** V E C T O R R E M A P P I N G *******************************************/
extern void _startup (void); // See c018i.c in your C18 compiler dir
#pragma code _RESET_INTERRUPT_VECTOR = 0x000800
void _reset (void)
{
_asm goto _startup _endasm
}
#pragma code
#pragma code high_vector=0x08
void interrupt_at_high_vector(void)
{
_asm GOTO high_isr _endasm
}
#pragma code /* return to the default code section */
#pragma interrupt high_isr
void high_isr(void)
{
INTCON3bits.INT1IF = 0; //CLEAR INT FLAG
}
/** D E C L A R A T I O N S **************************************************/
#pragma code
/*******LCD************/
#define RS PORTAbits.RA3
#define E PORTAbits.RA4
//CONTROL PINS
#define DAT4 PORTAbits.RA5
#define DAT5 PORTEbits.RE0
#define DAT6 PORTEbits.RE1
#define DAT7 PORTEbits.RE2
//Test LEDs
#define LED1 PORTDbits.RD1
#define LED2 PORTBbits.RB2
#define LED3 PORTBbits.RB0
#define Flow_bit PORTBbits.RB1 //For interrupt check
void initall(void){
TRISAbits.TRISA3=0;
TRISAbits.TRISA4=0;
TRISAbits.TRISA5=0;
TRISEbits.TRISE0=0;
TRISEbits.TRISE1=0;
TRISEbits.TRISE2=0;
TRISBbits.TRISB1=1;
TRISBbits.TRISB0=0;
TRISBbits.TRISB2=0;
TRISDbits.TRISD1=0;
}
void EnableExternalTimers(void)
{
T1CONbits.TMR1ON=0; // stop timer
T1CONbits.TMR1CS=1; // transition on T13CKI pin
T1CONbits.T1CKPS1=0; // prescalar 00
T1CONbits.T1CKPS0=0; // prescalar 00
T1CONbits.T1RUN=0; // device clock from another source
T1CONbits.T1OSCEN=0; // osc shut for power
T1CONbits.T1SYNC=0; // syncronisation
TMR1H = 0; // clear timer
TMR1L = 0; // clear timer
T1CONbits.TMR1ON=1; // start timer
PIE1bits.TMR1IE = 0; // interrupt disable
}
//#pragma interrupt change
void main(void)
{
int a = 0;
int b=0;
int c=0;
char z[9] = "IIT Delhi";
char z1[7] = "BTP-SWH";
ADCON1 |= 0x0D; // Default all pins to digital, except 2
OpenADC( ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_16_TAD , ADC_CH0 & ADC_INT_OFF & ADC_REF_VDD_VSS , ADC_1ANA ); //robotics club
//OpenADC( ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_16_TAD , ADC_CH1 & ADC_INT_OFF & ADC_REF_VDD_VSS , ADC_2ANA );
EnableExternalTimers();
initall(); LCDinit(); ClearScreen();
WriteStringL(z,9); Delay_ms(1000); ClearScreen();
WriteStringL(z1,7); Delay_ms(1000); ClearScreen();
WriteInt(9,2); Delay_ms(1000); ClearScreen();
WDTCONbits.SWDTEN = 0; //WDT disabled
//RCONbits.IPEN = 1; //Enabling high priority interrupt
INTCON3bits.INT1IF =0; //External interrupt 1 Flag
INTCONbits.GIE = 1; //Global interrupt enable
INTCON3bits.INT1IE = 1; //External interrupt 1 enable
INTCON2bits.INTEDG1 = 1; //Rising edge interrupt
//INTCON3bits.INT1IP = 1; //High Priority interrupt
while(1)
{
LED1 = 1; Delay_ms(100);
Sleep();
INTCONbits.GIE = 1;
INTCON3bits.INT1IE = 1;
INTCON2bits.INTEDG1 = 1;
LED1 = 0; Delay_ms(100);
WriteStringL(z,9); Delay_ms(1000); ClearScreen();
}
}
//end
/** EOF Demo02.c *************************************************************/
#pragma code _RESET_INTERRUPT_VECTOR = 0x000800
#pragma code _RESET_INTERRUPT_VECTOR = 0x00000
MPLINK 4.21, Linker
Copyright (c) 2008 Microchip Technology Inc.
Error - section '_entry_scn' can not fit the absolute section. Section '_entry_scn' start=0x00000000, length=0x00000006
Errors : 1
/** I N C L U D E S **********************************************************/
#include <p18f4550.h>
#include<adc.h>
#include<delays.h>
#include<timers.h>
#include<portb.h>
/** V A R I A B L E S ********************************************************/
#pragma udata
//void change(void);
void high_isr(void);
void initall(void);
void init_LCD4(void);
void OpenLCD(void);
void WriteCmd(unsigned char a);
void WriteChar(unsigned char a);
void WriteString(char* tolcd);
void WriteStringL(char* tolcd,int l);
void WriteInt(int i,int l);
void WriteLong(long i,int l);
void WriteULong(unsigned long i,int l);
void ClearScreen(void);
void ResetCursor(void);
void MoveToDisplay(unsigned char a);
void ShiftDisplayRight(int i);
void ShiftDisplayLeft(int i);
void LCDinit(void);
void Delay_s(int i);
void Delay_ms(int i);
void Delay_us(int i);
/** V E C T O R R E M A P P I N G *******************************************/
#pragma code high_vector=0x08
void interrupt_at_high_vector(void)
{
_asm GOTO high_isr _endasm
}
#pragma code /* return to the default code section */
#pragma interrupt high_isr
void high_isr(void)
{
INTCON3bits.INT1IF = 0; //CLEAR INT FLAG
}
/** D E C L A R A T I O N S **************************************************/
#pragma code
/*******LCD************/
#define RS PORTAbits.RA3
#define E PORTAbits.RA4
//CONTROL PINS
#define DAT4 PORTAbits.RA5
#define DAT5 PORTEbits.RE0
#define DAT6 PORTEbits.RE1
#define DAT7 PORTEbits.RE2
//Test LEDs
#define LED1 PORTDbits.RD1
#define LED2 PORTBbits.RB2
#define LED3 PORTBbits.RB0
#define Flow_bit PORTBbits.RB1 //For interrupt check
void initall(void){
TRISAbits.TRISA3=0;
TRISAbits.TRISA4=0;
TRISAbits.TRISA5=0;
TRISEbits.TRISE0=0;
TRISEbits.TRISE1=0;
TRISEbits.TRISE2=0;
TRISBbits.TRISB1=1;
TRISBbits.TRISB0=0;
TRISBbits.TRISB2=0;
TRISDbits.TRISD1=0;
}
void EnableExternalTimers(void)
{
T1CONbits.TMR1ON=0; // stop timer
T1CONbits.TMR1CS=1; // transition on T13CKI pin
T1CONbits.T1CKPS1=0; // prescalar 00
T1CONbits.T1CKPS0=0; // prescalar 00
T1CONbits.T1RUN=0; // device clock from another source
T1CONbits.T1OSCEN=0; // osc shut for power
T1CONbits.T1SYNC=0; // syncronisation
TMR1H = 0; // clear timer
TMR1L = 0; // clear timer
T1CONbits.TMR1ON=1; // start timer
PIE1bits.TMR1IE = 0; // interrupt disable
}
//#pragma interrupt change
void main(void)
{
int a = 0;
int b=0;
int c=0;
char z[9] = "IIT Delhi";
char z1[7] = "BTP-SWH";
ADCON1 |= 0x0D; // Default all pins to digital, except 2
OpenADC( ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_16_TAD , ADC_CH0 & ADC_INT_OFF & ADC_REF_VDD_VSS , ADC_1ANA ); //robotics club
//OpenADC( ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_16_TAD , ADC_CH1 & ADC_INT_OFF & ADC_REF_VDD_VSS , ADC_2ANA );
EnableExternalTimers();
initall(); LCDinit(); ClearScreen();
WriteStringL(z,9); Delay_ms(1000); ClearScreen();
WriteStringL(z1,7); Delay_ms(1000); ClearScreen();
WriteInt(9,2); Delay_ms(1000); ClearScreen();
WDTCONbits.SWDTEN = 0; //WDT disabled
//RCONbits.IPEN = 1; //Enabling high priority interrupt
INTCON3bits.INT1IF =0; //External interrupt 1 Flag
INTCONbits.GIE = 1; //Global interrupt enable
INTCON3bits.INT1IE = 1; //External interrupt 1 enable
INTCON2bits.INTEDG1 = 1; //Rising edge interrupt
//INTCON3bits.INT1IP = 1; //High Priority interrupt
while(1)
{
LED1 = 1; Delay_ms(100);
Sleep();
INTCONbits.GIE = 1;
INTCON3bits.INT1IE = 1;
INTCON2bits.INTEDG1 = 1;
LED1 = 0; Delay_ms(100);
WriteStringL(z,9); Delay_ms(1000); ClearScreen();
}
}
//end
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
Four of the PORTB pins (RB7:RB4) have an interrupt-on-change feature. Only pins configured as inputs can cause this interrupt to occur. Any RB7:RB4 pin configured as an output is excluded from the interrupt-on-change comparison.
// LCD module connections
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections
unsigned char temp;
void interrupt(void){
RD0_bit = 1; //To see if interrupt is triggered
delay_ms(500);
RD0_bit = 0;
//Delay_ms(2000);
temp = PORTB;
RBIF_bit = 0; //Clear RB interrupt flag
}
void main(){
//----------------------------------------------------------------------------
INTCON.GIE = 1; // Disable GIE, PEIE, TMR0IE,INT0IE,RBIE
INTCON.RBIE = 1; // Disable GIE, PEIE, TMR0IE,INT0IE,RBIE
INTCON2 = 0xF5;
INTCON3 = 0xC0;
RCON.IPEN = 0; // Disable Priority Levels on interrupts
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;
ADCON1 |= 0x0F; // Configure all ports with analog function as digital
CMCON |= 7; // Disable comparators
//----------------------------------------------------------------------------
TRISD = 0;
PORTD = 0;
PORTB = 0xFF;
TRISB = 0xFF;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
while(1){
Lcd_Out(1,3,"Hello World");
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?