EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / need help with an isr code

need help with an isr code

|

Microcontroller › PIC › need help with an isr code

  • This topic has 3 replies, 3 voices, and was last updated 8 years, 10 months ago by sara.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • October 31, 2016 at 2:27 am #4572
    ale
    Participant

    hello, i am new to to pic mcu's and i have been fooling arround with a pic18f4620, my problem is that whenever i wanto to make an ISR with timer0 the program will not enter the ISR, here i show you the code, please if you can help me i would be very gratefull.

     

    /* 
     * File:   test1main.c
     * Author: aleso
     *
     * Created on 11 de septiembre de 2016, 15:02
     */
     
     
    // PIC18F4620 Configuration Bit Settings
     
    // 'C' source line config statements
     
     
    // PIC18F4620 Configuration Bit Settings
     
    // 'C' source line config statements
     
    #include <p18F4620.h>
     
    // CONFIG1H
    #pragma config OSC = RC         // Oscillator Selection bits (External RC oscillator, CLKO function on RA6)
    #pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
    #pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
     
    // CONFIG2L
    #pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)
    #pragma config BOREN = SBORDIS  // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
    #pragma config BORV = 3         // Brown Out Reset Voltage bits (Minimum setting)
     
    // CONFIG2H
    #pragma config WDT = OFF        // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
    #pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)
     
    // CONFIG3H
    #pragma config CCP2MX = PORTC   // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
    #pragma config PBADEN = ON      // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
    #pragma config LPT1OSC = OFF    // Low-Power Timer1 Oscillator Enable bit (Timer1 configured for higher power operation)
    #pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
     
    // CONFIG4L
    #pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
    #pragma config LVP = ON         // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
    #pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
     
    // CONFIG5L
    #pragma config CP0 = OFF        // Code Protection bit (Block 0 (000800-003FFFh) not code-protected)
    #pragma config CP1 = OFF        // Code Protection bit (Block 1 (004000-007FFFh) not code-protected)
    #pragma config CP2 = OFF        // Code Protection bit (Block 2 (008000-00BFFFh) not code-protected)
    #pragma config CP3 = OFF        // Code Protection bit (Block 3 (00C000-00FFFFh) not code-protected)
     
    // CONFIG5H
    #pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block (000000-0007FFh) not code-protected)
    #pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM not code-protected)
     
    // CONFIG6L
    #pragma config WRT0 = OFF       // Write Protection bit (Block 0 (000800-003FFFh) not write-protected)
    #pragma config WRT1 = OFF       // Write Protection bit (Block 1 (004000-007FFFh) not write-protected)
    #pragma config WRT2 = OFF       // Write Protection bit (Block 2 (008000-00BFFFh) not write-protected)
    #pragma config WRT3 = OFF       // Write Protection bit (Block 3 (00C000-00FFFFh) not write-protected)
     
    // CONFIG6H
    #pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write-protected)
    #pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected)
    #pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
     
    // CONFIG7L
    #pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 (000800-003FFFh) not protected from table reads executed in other blocks)
    #pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 (004000-007FFFh) not protected from table reads executed in other blocks)
    #pragma config EBTR2 = OFF      // Table Read Protection bit (Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks)
    #pragma config EBTR3 = OFF      // Table Read Protection bit (Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks)
     
    // CONFIG7H
    #pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot Block (000000-0007FFh) not protected from table reads executed in other blocks)
     
     
     
     
    #include <p18f4620.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <timers.h>
    #include <delays.h>
    char i=0;
     
    //


     // High priority interrupt routines
     //


     #pragma interrupt high_isr 
     void high_isr(void)
     {
      if (INTCONbits.TMR0IF && INTCONbits.TMR0IE) // TMR0 Interrupt
      {
            LATDbits.LATD0=PORTDbits.RD0;
            i=i+1;
            WriteTimer0(254);
            INTCONbits.TMR0IF = 0; // clear flag
      }
     
     }
     
     
     //


     // High priority interrupt vector
     //


     #pragma code high_vector=0x08
     void high_interrupt(void)
     {
      _asm GOTO high_isr _endasm
     }
     #pragma code /* return to the default code section */
     
    //char j=1;
    void main ()
    {
        TRISD=0b00000000;
        LATD=0b00000000;
        RCONbits.IPEN=0;
        INTCONbits.GIE=1;
        INTCONbits.PEIE=1;
        INTCONbits.TMR0IE=1;
        T0CON=0b01011000;
        T0CONbits.TMR0ON=1;
        //OpenTimer0(TIMER_INT_ON & T0_8BIT & T0_SOURCE_INT & T0_EDGE_FALL & T0_PS_1_1);
        //WriteTimer0(255);
        while (1)
        {
            //LATDbits.LATD0=!PORTDbits.RD0;
            //Delay10TCYx(j);
            //j=j+1;
        }
    }
    October 31, 2016 at 2:30 am #14224
    ale
    Participant

    i am using the C18 compiler and a pickit3 for this one

    January 26, 2017 at 2:45 pm #14378
    samarth udgiri
    Participant

    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

    char txt1[] = "mikroElektronika";
    char txt2[] = "EasyPIC6";
    char txt3[] = "Lcd4bit";
    char txt4[] = "example";

    char i;                              // Loop variable

    void Move_Delay() {                  // Function used for text moving
     Delay_ms(500);                     // You can change the moving speed here
    }

    void main(){
    //  ANSEL  = 0;                        // Configure AN pins as digital I/O
    //  ANSELH = 0;
    //  C1ON_bit = 0;                      // Disable comparators
    //  C2ON_bit = 0;
     CMCON = 7;             // turn off comparators
     ADCON1 = 0x0F;           // turn off analog inputs

     TRISA = 0x00;
     TRISE = 0x00;                        // PORTB is output
     TRISB = 0x00;

     delay_ms(100);
     Lcd_Init();                        // Initialize LCD

     Lcd_Cmd(_LCD_CLEAR);               // Clear display
     Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
     Lcd_Out(1,6,txt3);                 // Write text in first row

     Lcd_Out(2,6,txt4);                 // Write text in second row
     Delay_ms(2000);
     Lcd_Cmd(_LCD_CLEAR);               // Clear display

     Lcd_Out(1,1,txt1);                 // Write text in first row
     Lcd_Out(2,5,txt2);                 // Write text in second row

     Delay_ms(2000);

     // Moving text
     for(i=0; i<4; i++) {               // Move text to the right 4 times
     Lcd_Cmd(_LCD_SHIFT_RIGHT);
     Move_Delay();
     }

     while(1) {                         // Endless loop
     for(i=0; i<8; i++) {             // Move text to the left 7 times
     Lcd_Cmd(_LCD_SHIFT_LEFT);
     Move_Delay();
     }

     for(i=0; i<8; i++) {             // Move text to the right 7 times
     Lcd_Cmd(_LCD_SHIFT_RIGHT);
     Move_Delay();
     }
     }
    }

     

    Can anyone tell me the compiler for this code.

    i need as soon as possible.

    if anyone knows the tell me it will be helpfull for me.

    February 1, 2017 at 6:40 am #14391
    sara
    Participant

    use another compiler

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Please confirm monostable does not need reset? December 15, 2025
  • Multiple photodiodes for single ADC read December 15, 2025
  • Bringing a Siemens W-48 and Ericsson Model 1951 back to life December 15, 2025
  • Hitachi SuperScan Elite 802 CRT Monitor Issues (Model CM802U) December 15, 2025
  • Sound not working on Laptop December 15, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise