12.07.2015 Views

TP 1 : Introduction

TP 1 : Introduction

TP 1 : Introduction

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>TP</strong>2 : découverte du Timer et de l'affichage numériqueExercice 1On désire compter sur 8 bits au rythme d’un timer. La face avant ne comportera donc quehuit leds (appelées LED, LED_2, …,LED_8) et un bouton quit. De plus, il faudra lui ajouter untimer avec son callback associé :TypeConstant NameTIMERCallback Function MaJInterval(seconds)Label1.000Timertimer.Cela peut ressembler à la figure ci-dessous :break;}return 0;}Le callback MaJ sera responsable l’incrémentation d’une variable (locale statique) sur 8 bitset de son affichage sur 8 leds. On procédera de la manière suivante : incrémentation de lavariable puis conversion dans un tableau de 8 cases entières puis appel de 8 SetCtrlValpour chacune des 8 leds. On vous donne le canevas ci-dessous que vous avez à compléter.int CVICALLBACK MaJ (int panel, int control, int event,void *callbackData, int eventData1, int eventData2){ int leds[8];static unsigned char nb=0; // explication du terme static !!!!int CVICALLBACK MaJ (int panel, int control,int event,void *callbackData, inteventData1, int eventData2){switch (event){case EVENT_COMMIT:}switch (event){case EVENT_TIMER_TICK:// calcul de la nouvelle valeurnb++;conversion(nb,leds);// Mise à jour des ledsSetCtrlVal(panelHandle,PANEL_LED,leds[0]);SetCtrlVal(panelHandle,PANEL_LED_2,leds[1]);....void conversion(unsigned char nb, int result[8]); pourra être réalisé comme cidessous:3 /18 Licence CESA 2007/2008 (IUT Troyes) S. Moutou

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!