Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pingiono32 OnTimer Error
12-12-2014, 12:59 AM, (This post was last modified: 12-12-2014, 01:00 AM by jwzumwalt.)
#1
Pingiono32 OnTimer Error
When I attempt to use the timer function I get a compile error

OnTimer1(myBlink1, INT_MILLISEC, 200);
"'INT_MILLISEC' undeclared (first use in this function)"


has someone figured out what compiler file is needed for Pinguino32?

thanks
Reply
12-12-2014, 01:58 AM, (This post was last modified: 12-12-2014, 01:58 AM by pingotg.)
#2
RE: Pingiono32 OnTimer Error
As the wiki says, 32-bit OnTimer (etc) is under development i.e. not done yet - sadly.

John
Reply
12-12-2014, 09:51 AM,
#3
RE: Pingiono32 OnTimer Error
(12-12-2014, 01:58 AM)pingotg Wrote: As the wiki says, 32-bit OnTimer (etc) is under development i.e. not done yet - sadly.

John

Doe the PIC32 IDE provide configuration bit access so I could setup the timer manually?
Reply
12-12-2014, 10:43 AM,
#4
RE: Pingiono32 OnTimer Error
Hi

There are some sample program which use interrupt on P32 boards.

You can found it in examples\08.Interrupt\ folder

They are:
P32-FrequencyMeter80MHz.pde
P32-Interrupt-Timer1.pde
P32-PeriodMeter80MHz.pde


Bye Bye, Moreno
Reply
12-12-2014, 11:34 AM,
#5
RE: Pingiono32 OnTimer Error
Oh yes!

Bug in P32-Interrupt-Timer1.pde!! Needs volatile ... counter

John
Reply
12-12-2014, 08:30 PM, (This post was last modified: 12-12-2014, 08:31 PM by jwzumwalt.)
#6
RE: Pingiono32 OnTimer Error
(12-12-2014, 10:43 AM)moreno Wrote: Hi

There are some sample program which use interrupt on P32 boards.

You can found it in examples\08.Interrupt\ folder

They are:
P32-FrequencyMeter80MHz.pde
P32-Interrupt-Timer1.pde
P32-PeriodMeter80MHz.pde


Bye Bye, Moreno

THANKS!!
I'll take a look at these today.
I hope to do a minimal proof of concept "blinky" program
and if I can get it going I will shar it Smile
Reply
12-12-2014, 11:08 PM, (This post was last modified: 16-12-2014, 09:15 PM by jwzumwalt.)
#7
Lightbulb  RE: Pingiono32 OnTimer Error
Thanks for the help folks - here is tested code Smile
Interrupt and setup routine modified per suggestions by Moreno
Code:
/* ----------------------------------------------------------------------------
  p32-blink_timer - blink led using interrupt timer1
  ----------------------------------------------------------------------------
  author:   Jan Zumwalt
  created:  2014.12.12
  revised:  2014.12.13
  ide:      x4-easy-rev959
  board:    pic32-pinguino-micro
  cpu:      pic32-mx440f256h 80mhz
  notes:    
  ----------------------------------------------------------------------------  */

 // -----   global constants, defines, includes and variables   -----
 
 #include <interrupt.c>
 
 // PRESCALE combined with TIMERPERIOD = total timer period
 const unsigned int PRESCALE = 48 ;      // don't mess with this unless you know what you are doing
 const unsigned int TIMERPERIOD = 39062; // user modifiable - use this to adjust timer period
   
 // -----   support routines   -----
 
 // Put the ISR_wrapper in the good place
 void __attribute__ ((nomips16)) ISR_wrapper_vector_4(void) __attribute__ ((section (".vector_4")));
 // Tmr1Interrupt is declared as an interrupt routine
 void __attribute__ ((nomips16))  Tmr1Interrupt(void) __attribute__ ((interrupt));
 // ISR_wrapper will call the Tmr1Interrupt()
 void __attribute__ ((nomips16)) ISR_wrapper_vector_4(void) { Tmr1Interrupt(); }
 
  // configure timer 1
 void init_timer1(void) {
 IntConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);    // interrupt mode (interrupt.c)
 T1CON=0;                         // reset timer 1 configuration
 TMR1=0;                                 // reset timer 1 counter register
 PR1=TIMERPERIOD;                 // define the preload register (timer period)
 IPC1SET=0x7;                     // select interrupt priority and sub-priority
 IFS0CLR=0x10;                         // clear interrupt flag
 IEC0SET=0x10;                         // enable timer 1 interrupt
 T1CONSET=PRESCALE;               // set prescaler value
 T1CONSET=0x8000;                 // turn TIMER1 ON
 }
 
 /* --------------------------------------------------------------
              this routine executes each time timer fires
    --------------------------------------------------------------  */
 void  __attribute__ ((nomips16))  Tmr1Interrupt(void) {
   if (IFS0bits.T1IF)   {         // Timer Interrupt flag
     TMR1=0;                      // reset the timer register
     IFS0CLR=0x10;                // Clear the timer interrupt flag

     toggle(YELLOWLED);           // toggle yellow led
     toggle(GREENLED);            // toggle green led    
   }
 }
 
 /* --------------------------------------------------------------
                          setup / initialize
    --------------------------------------------------------------  */
 void setup() {                   // do once
 pinMode(YELLOWLED, OUTPUT);      // pin i/o direction
 pinMode(GREENLED, OUTPUT);       // pin i/o direction
 digitalWrite(YELLOWLED,OFF);     // init yellow led off
 digitalWrite(GREENLED,ON);       // init green led on
 init_timer1();
 }
 
 /* --------------------------------------------------------------
                           main program loop
    --------------------------------------------------------------  */
 void loop() {                    // do repeatedly
   // nothing to do, the interrupt routine does it all
 }
Reply
13-12-2014, 09:26 AM,
#8
RE: Pingiono32 OnTimer Error
Hi

From my point of view there are some minor potential flaws.

Code:
/* --------------------------------------------------------------
              this routine executes each time timer fires
    --------------------------------------------------------------  */
void  __attribute__ ((nomips16))  Tmr1Interrupt(void) {
   if (IFS0bits.T1IF)   {         // Timer Interrupt flag
     TMR1=0;                      // reset the timer register
     IFS0CLR=0x10;                // Clear the timer interrupt flag
     toggle(YELLOWLED);             // toggle yellow led
     toggle(GREENLED);              // toggle green led    
   }
}

/* --------------------------------------------------------------
                          setup / initialize
    --------------------------------------------------------------  */
void setup() {                   // do once
pinMode(YELLOWLED, OUTPUT);      // pin i/o direction
pinMode(GREENLED, OUTPUT);       // pin i/o direction
digitalWrite(YELLOWLED,OFF);     // init yellow led off
digitalWrite(GREENLED,ON);       // init green led on
init_timer1();
}


Bye Bye, Moreno
Reply
13-12-2014, 11:28 PM, (This post was last modified: 13-12-2014, 11:29 PM by jwzumwalt.)
#9
RE: Pingiono32 OnTimer Error
(13-12-2014, 09:26 AM)moreno Wrote: Hi

From my point of view there are some minor potential flaws.
 ...
 ...
Bye Bye, Moreno

Hello Moreno,
Thank you for the suggestions. The code I used was from two
programs - neither that was complete or without problems.

I did a Google search of you suggestions and found other examples
of people following your recommendation. However I do not really
understand what the difference is with __attribute__ ((nomips16)).

Would you please explain why this is important? Or, point me to
documentation I can read about mips16 vs nomips16?
(Is this disabling interrupts while the routine is processed?)
----------------
Thanks,
j
wzumwalt
 (\__/)
 (='.'=)
 (")_(")
Reply
14-12-2014, 11:39 AM,
#10
RE: Pingiono32 OnTimer Error
Hi

Is very hard to explain and never I know all the history.

MIPS is a code optimization feature which reduce the compiled code size.

The problem is which the MIPS generated code is not compatible with interrupt routines, if you compile interrupt handler code without __attribute__ ((nomips16)) you obtain a lot of strange compiling errors.
Even the definition order of the routines is very important (I do not know why), if you change it nothing work.


Bye Bye, Moreno
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)