+ Post New Thread
Results 1 to 2 of 2
  1. #1
    Newbie level 6
    Points: 1,399, Level: 8

    Join Date
    Jun 2005
    Posts
    12
    Helped
    0 / 0
    Points
    1,399
    Level
    8

    iterrupt

    this code is good for an interrupt???
    #include <pic.h>
    #include <delay.c>
    #include <delay.h>
    main(){
    GIE=1; //--> enable global interrupt
    T0IE=1; //--> enable l'interrupt sul tmr0
    TRISD=0;
    TRISB=0;
    TRISC=0;
    while(1){
    PORTC=255;
    }

    }
    void interrupt prv_int(void)
    {
    unsigned int i=1;
    TRISB=0;
    TRISD=0;
    PORTD=0;
    PORTB=0;

    PORTD=1;

    if(T0IF){

    while(i<256){
    PORTB=i;
    i++;
    }
    T0IF=0; //Riabilita linterrupt flag
    } //altrimenti non
    } //vi saranno altri int TMR0
    /*-------------------- EOF interrupt ----------------*/

    •   Alt1st July 2005, 16:07

      advertising

        
       

  2. #2
    Full Member level 4
    Points: 4,144, Level: 15

    Join Date
    Nov 2004
    Location
    USA
    Posts
    211
    Helped
    44 / 44
    Points
    4,144
    Level
    15

    iterrupt

    You need to set up OPTION_REG to get your timer to work.

    If you want the timer to increment every clock cycle you would set OPTION_REG = B'00001000' (assuming you're using a PIC16F87X).



--[[ ]]--