se ti puo' aiutare :
#include "p30f4011.h" #include "p30fxxxx.h" #include "LCD_44780.h" #include "delay.h" #include "qei.h" #define FCY 30000000UL //Unsigned Long #include "libpic30.h"
/* impostazioni micro :*/ _FOSC(CSW_FSCM_OFF & FRC_PLL16); /* Set up for FCR and PLL x 16 120 mhz fcy 30mhz 30 mips */ _FWDT(WDT_OFF); /* Turn off the Watch-Dog Timer. */ _FBORPOR(MCLR_EN & PWRT_OFF); /* Enable MCLR reset pin and turn off the power-up timers. */ _FGS(CODE_PROT_OFF); /* Disable Code Protection */
//-------------------------------------------------------------------// // DEFINIZIONE COSTANTI // //-------------------------------------------------------------------//
#define led1 LATFbits.LATF4 #define led2 LATFbits.LATF5 #define step LATEbits.LATE4 #define direzione LATEbits.LATE3 #define enable LATEbits.LATE0 #define reset LATEbits.LATE5
#define pulsante1 PORTDbits.RD2 #define pulsante2 PORTFbits.RF1 #define pulsante3 PORTFbits.RF0 #define pulsante4 PORTEbits.RE8 #define ventola PORTEbits.RE2 #define PWMVREF 400 #define PWMFREF 000 #define RAPPORTO_RIDUZIONE 0.05495 #define RAPPORTO_CONVERSIONE_CORRENTE 2.5615 #define FWD 1 #define RWD 0 // ingressi digitali
//#define LCD-BACK LATFbits.LATF6
//-------------------------------------------------------------------// // VARIABILI GLOBALI // //-------------------------------------------------------------------// unsigned char state; unsigned int pos_value; unsigned int valore_eeprom[16]; unsigned int valore2_eeprom[16]; unsigned int table_ram[16]; char contatore_riga; char contatore_riga1; char contatore_riga_back; unsigned char conferma_salvataggio; unsigned char fase_ciclo; unsigned int n_impulsi_fw; unsigned int n_impulsi_rw; unsigned int n_impulsi_pausa; unsigned int n_impulsi; unsigned char status_step; unsigned char status_direzione; unsigned int velocita_FW; unsigned int velocita_RW; unsigned int lunghezza_FW; unsigned int lunghezza_RW; unsigned int t_pausa; unsigned int Tempo1; unsigned int Tempo2; unsigned int contatore_timer1; unsigned int canale0; unsigned int canale1; unsigned int canale2; unsigned int canale3; unsigned int canale0_old; unsigned int canale1_old; unsigned int canale2_old; unsigned int canale3_old; unsigned int FIR_1; unsigned int FIR_2; unsigned int contatore_timer2; unsigned int valore_corrente_start; unsigned int valore_corrente_stop; unsigned char fase_prog0; int corrente_misurata;
//-------------------------------------------------------------------// // INIZIALIZZAZIONE EEPROM // //-------------------------------------------------------------------//
unsigned int _EEDATA(32) table0[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; unsigned int _EEDATA(32) table1[16] = {1, 30, 5, 5, 5, 0, 1, 8, 2, 1, 1, 3, 8, 14, 15, 16,}; unsigned int _EEDATA(32) table2[16] = {2, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48,}; unsigned int _EEDATA(32) table3[16] = {3, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,}; unsigned int _EEDATA(32) table4[16] = {4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,};
//-------------------------------------------------------------------// // PROTOTIPI DI FUNZIONE // //-------------------------------------------------------------------//
void _ISR _INT0Interrupt(void); void _ISR _INT1Interrupt(void); void _ISR _INT2Interrupt(void); void _ISR _T1Interrupt(void); void _ISR _T2Interrupt(void); void _ISR _ADCInterrupt(void); void QEI_setup(void); void PWM_setup(void); void ADC_setup(void);
_________________ - internet + cabernet - V8 Power l'esperienza non si compra ma si paga
|