Search in Pinguino World !!

Sunday, December 25, 2011

How to use interrupt on Pinguino32

Pinguino32 doesn’t support interrupt routines without writing a code in an assembler file. We decided to open interrupt to everybody. To do this, we used some of the special attribute directive of GCC. Now you can deal with Interrupt without assembler.

This example show how to use the Timer 1 to increment a counter.

// Using interrupt with Pinguino32
// Jean-Pierre MANDON 2011


unsigned int counter=0;

void ISR_wrapper_vector_4(void) __attribute__ ((section (".vector_4")));
// Put the ISR_wrapper in the good place

void ISR_wrapper_vector_4(void) { Tmr1Interrupt(); }
// ISR_wrapper will call the Tmr1Interrupt()

void Tmr1Interrupt(void) __attribute__ ((interrupt));
// Tmr1Interrupt is declared as an interrupt routine

// define here the code to execute when an interrupt occure
void Tmr1Interrupt(void)
if (IFS0bits.T1IF) // Timer Interrupt flag
TMR1=0; // reset the timer register
IFS0CLR=0x10; // Clear the timer interrupt flag
counter++; // increment the counter

// 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=0x9999; // define the preload register
IPC1SET=0x7; // select interrupt priority and sub-priority
IFS0CLR=0x10; // clear interrupt flag
IEC0SET=0x10; // enable timer 1 interrupt
T1CONSET=0x8010; // start timer 1 and set prescaler

void setup()

void loop()
CDC.printf("%d\n\r",counter); // counter is incremented at each timer 1 overflow

Be careful, some interruption are already used by Pinguino32. Vector_8 (timer 2) is used by the function millis(). vector_24 (Serial1 interrupt) and vector_32 (Serial2 interrupt) are used by the serial module. vector_35 ( RTCC ) is used by the real time clock module.
All the test have been made with a PIC32-PINGUINO-OTG board and Linux IDE.


Unknown said...

Hola!, como se puede comunicar PINGUINO con EXCEL???? GRacias!!!

Unknown said...

Nice to see this post. This project (PINGUINO) it's still active ?
Kind Regards,

Anonymous said...

Breve introducción a Pinguino en castellano:

ellinonenosis said...


Do we first need to load the HEX files before using the pic to make a pinguino ?

jpmarcoleta said...

Bonjour monsieur Mandon,

Je suis étudiant du doctorad en Alemagne, je fait mon doctorad en éléctronique.
Je voudrais savoir, s'il y a la posibilité de envoiyer data du usb port á pinguino 32 et que le pinguino peux lire la data du port et fair son travaill.
La question puntuel, c'est si c'est posible de controller Pinguino 32 avec processing comme le pinguino 18f2550, et comment le faire.

Merci beaucoup pour votre réponse.

Juan Pablo

Артур Борис  said...

I’m Артур Борис a resident/citizen of the Republic Of Russian. I’m 52 years of age, an entrepreneur/businessman. I once had difficulties in financing my project/business, if not for a good friend of mine who introduced me to Mr Benjamin Lee to get a loan worth $250,000 USD from his company. When i contacted them it took just five working days to get my loan process done and transferred to my account. Even with a bad credit history, they still offer their service to you. They also offer all kinds of loan such as business loans, home loans, personal loans, car loans. I don’t know how to thank them for what they have done for me but God will reward them according to his riches in glory. If you need an urgent financial assistance contact them today via email  WhatsApp information...+1-989-394-3740

Ramya said...

Great one to find the working xbox $50 codes

Ramya said...

It is very easy to use roblox gift card

inster-omtemplates said...

check once ebay gift codes