Problems compiling Interrupt Code

Beta Testing discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Problems compiling Interrupt Code

#1 Post by p.erasmus » 05 Feb 2011 14:21

Dear Team
When I try to compile the Timer1 interrupt example for the PIC32MX460F512L
from the Compiler examples Folder
I get Failed with no errors and no error hint is given ,however the EnableInterrupt Function
in the initialization code remains underlined in Red as if the compiler does not find this function
I then made a new Project and used the Interrupt tool to generate me the interrupt handler for
Timer 1 this Interrupt handler does not compiler !!
I did read the Help file :D

Code: Select all

        /*
 * Project name:
     Timer1_interrupt (Timer1 interrupt test)
 * Copyright:
     (c) Mikroelektronika, 2009.
 * Revision History:
     20091106:
       - Initial release;
 * Description:
     This code demonstrates how to use Timer1 and it's interrupt.
     Program toggles LEDs on PORTB.
 * Test configuration:
     MCU:             P32MX460F512L
                      http://ww1.microchip.com/downloads/en/DeviceDoc/61143G.pdf
     Dev.Board:       LV32MX v6
                      http://www.mikroe.com/eng/products/view/462/lv-32mx-v6-development-system/
     Oscillator:      XT-PLL, 80.000MHz
     Ext. Modules:    None.
     SW:              mikroC PRO for PIC32
                      http://www.mikroe.com/eng/categories/view/89/pic32-compilers/
 * NOTES:
     - Use the ORG directive to declare your procedure as an interrupt service routine.
       The address after the ORG statement indicates which interrupt you will assign to
       your procedure.
       Please consult the datasheet for your MCU for interrupt vector table
       details and available addresses.
     - Also, consult mikroC PRO for PIC32 help on how to use interrupts.
 */
 
void Timer1_interrupt() iv IVT_TIMER_1 ilevel 7 ics ICS_SRS
{
  T1IF_bit = 0;             // Clear T1IF
  LATB = ~ PORTB;           // Invert PORTB
}

void main() {
  AD1PCFG = 0xFFFF;         // Initialize AN pins as digital
  TRISB  = 0;               // initialize PORTB as output
  LATB   = 0xAAAA;          // Initialize PORTB value
  
  TMR1 = 0;                 // reset timer value to zero
  PR1 = 65535;              // Load period register

  T1IP0_bit = 1;            // set interrupt
  T1IP1_bit = 1;            // priority
  T1IP2_bit = 1;            // to 7

  TCKPS0_bit = 1;           // Set Timer Input Clock
  TCKPS1_bit = 1;           // Prescale value to 1:256
  EnableInterrupts();       // Enable all interrupts

  T1IE_bit = 1;             // Enable Timer1 Interrupt
  ON__T1CON_bit = 1;        // Enable Timer1
}
my project

Code: Select all

//------------------------------------------------------------------------
void MC_Init(void);

//-------------------------------------------------------------------------
void main() 
{
   DDPCONbits.JTAGEN = 0;
   TRISA =  0;
   PORTA = 0;
   MC_Init();
 while(1)
  {
      LATA.B0 = ~PORTA.B0;
      Delay_ms(500);


  }
}
//--------------------------------------------------------------------------
//Timer Interrupt
//--------------------------------------------------------------------------
void Timer1_Interrupt() iv IVT_TIMER_1 ilevel 7 ics ICS_SRS
{
  T1IF_bit = 0;                      // Clear T1IF
  LATB.B1 = ~ PORTB.B1;       // Invert PORTB
}
//-------------------------------------------------------------------------
void MC_Init()
{
  AD1PCFG = 0xFFFF;         // Initialize AN pins as digital
  TRISB  = 0;               // initialize PORTB as output
  LATB   = 0xAAAA;          // Initialize PORTB value

  TMR1 = 0;                 // reset timer value to zero
  PR1 = 65535;              // Load period register

  T1IP0_bit = 1;            // set interrupt
  T1IP1_bit = 1;            // priority
  T1IP2_bit = 1;            // to 7

  TCKPS0_bit = 1;           // Set Timer Input Clock
  TCKPS1_bit = 1;           // Prescale value to 1:256
  EnableInterrupts();       // Enable all interrupts

  T1IE_bit = 1;             // Enable Timer1 Interrupt
  ON__T1CON_bit = 1;        // Enable Timer1
}

Attachments
2.png
2.png (11.08 KiB) Viewed 7217 times
Missing function.png
Missing function.png (16.81 KiB) Viewed 7217 times
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

Acetronics
Posts: 715
Joined: 27 Dec 2006 14:33
Location: Le Tréport , FRANCE

Re: Problems compiling Interrupt Code

#2 Post by Acetronics » 05 Feb 2011 15:24

Hi,

Did you try to place your " functions " BEFORE ... the main part ???

looks to work fine ... whatever the compiler. :wink:

Alain

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: Problems compiling Interrupt Code

#3 Post by p.erasmus » 05 Feb 2011 15:29

Alain
With me it does not matter the same story and it should actually not matter
as I have a Function proto type before the main :wink:
Dont forget I said the Example code does not compile aswell with me were all functions are bedfore the main ,
As far as I know in ANSI C you are allowed to place functions after the main or in other modules as long as there is a
function proto type before the main or in a .h file which is called before the main in which the function is called.
Attachments
3.png
3.png (24.55 KiB) Viewed 7204 times
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: Problems compiling Interrupt Code

#4 Post by p.erasmus » 05 Feb 2011 15:52

Alian

Thank you for checking on your system that the code compiles,
I uninstalled the compiler and installed it again ,
Both the example and my code functions now ; I will run the hex file now on my
explorer 16 board

Thanks for your efforts and the compiler excepts the functions after the main with a function
proto type

Peter
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: Problems compiling Interrupt Code

#5 Post by p.erasmus » 05 Feb 2011 15:57

The Red Line under the EnableInterrupts() remains
were is this function located as I find no info in the help file
regarding this function ,
Attachments
5.png
5.png (4.46 KiB) Viewed 7200 times
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

Acetronics
Posts: 715
Joined: 27 Dec 2006 14:33
Location: Le Tréport , FRANCE

Re: Problems compiling Interrupt Code

#6 Post by Acetronics » 05 Feb 2011 16:42

p.erasmus wrote:The Red Line under the EnableInterrupts() remains
were is this function located as I find no info in the help file
regarding this function ,
I also have it when writing " PORTA.F0 " ... under F0 ... ( with MikroC Pro 8 bits too ...) or if I use labels

doesn't seem to be a problem !!!

Better if not underlined, but ... may be in a further release ( :lol: )

Alain

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: Problems compiling Interrupt Code

#7 Post by p.erasmus » 05 Feb 2011 16:45

Hi

The code functions I ran it in my Explorer 16 Board with no problem
I just dont like the Red lines !!
Happy saturday

Peter
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

Re: Problems compiling Interrupt Code

#8 Post by srdjan » 07 Feb 2011 14:54

Hi,
The code works, but spell checker does not recognize the identifier.
Fixed.
Thanks.

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: Problems compiling Interrupt Code

#9 Post by p.erasmus » 07 Feb 2011 20:33

@srdjan

Thank you for the fix :D
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

Post Reply

Return to “mikroC PRO for PIC32 Beta Testing”