Però mi appalla scrivere tutte quelle funzioni void, se ci fosse un modo per puntare a delle semplici label da cui uscire con un goto.. scherzavo.
A proposito, come si termina correttamente un programma?
- Codice: Seleziona tutto
#include "fusebit.c"//osc.fastRC with PLL e tutto libero
#include "p33FJ128MC802.h"
//_FOSCSEL (FNOSC_FRCPLL & IESO_ON)//FastRC 7,37 MHz wPLL
#define ledr _LATA4 // RA4 pin12 led rosso (come scheda MUIN)
#define ledv _LATB4 // RB4 pin11 led verde
void lab1() {ledr=1;}
void lab2() {ledv=1;}
int main (void) { //Main Program
PLLFBDbits.PLLDIV=41;//PLLDIV=41 M=43 clock Tcy=25 ns
CLKDIVbits.PLLPOST=0;//N1=2 N2=2(def) 7.37*M/N1/N2=79Mhz~40MIPS
while (OSCCONbits.COSC != 0b001){}; // Sure for FastRC w PLL
while(OSCCONbits.LOCK!=1) {}; // Wait for PLL to lock
TRISA = 0b1111111111101111; //OUT RA4 PIN12 LED rosso
TRISB = 0b1111111111101111; //OUT RB4 PIN11 LED verde
void (*fun_ptr_arr[])() = {lab1, lab2};
(*fun_ptr_arr[0])();//accende il led rosso
kk:goto kk;}