0
@@ -134,7 +134,7 @@ INTCON = 0; // disattiva tutti gli interrupt
0
INTCONbits.GIE = 1; // attiva interrupt UART e Timer
0
-for (S1=0;S1<10
;S1++) // fa lampeggiare il LED
0
+for (S1=0;S1<10
0;S1++) // fa lampeggiare il LED
0
@@ -187,117 +187,25 @@ TXcount = 0;
0
- if (INTCONbits.TMR0IF)
0
- ServoCiclo(); // gestione servi
0
+ // if (INTCONbits.TMR0IF)
0
+ // ServoCiclo(); // gestione servi
0
- SetDCPWM1(PWM1); // PWM1 e PWM2
0
- if(ParsFlag) Parser(); // analisi comandi
0
+ // SetDCPWM1(PWM1); // PWM1 e PWM2
0
+ // if(ParsFlag) Parser(); // analisi comandi
0
+ WriteUSART("Greetings from the MuIN!\r\n");
0
/* ---------- fime main ---------- */
0
- TMR1H = (65536 - S1*10) >> 8;
0
- TMR1L = (65536 - S1*10);
0
- TMR3H = (65536 - S2*10) >> 8;
0
- TMR3L = (65536 - S2*10);
0
- TMR1H = (65536 - S3*10) >> 8;
0
- TMR1L = (65536 - S3*10);
0
- TMR3H = (65536 - S4*10) >> 8;
0
- TMR3L = (65536 - S4*10);
0
- TMR1H = (65536 - S5*10) >> 8;
0
- TMR1L = (65536 - S5*10);
0
- TMR3H = (65536 - S6*10) >> 8;
0
- TMR3L = (65536 - S6*10);
0
- TMR1H = (65536 - S7*10) >> 8;
0
- TMR1L = (65536 - S7*10);
0
- TMR3H = (65536 - S8*10) >> 8;
0
- TMR3L = (65536 - S8*10);
0
- SetChanADC( ADC_CH0 ); // legge un canale dell'ADC
0
- SetChanADC( ADC_CH1 );
0
- SetChanADC( ADC_CH2 );
0
- SetChanADC( ADC_CH3 );
0
- SetChanADC( ADC_CH4 );
0
void ISRgest(void) // I.S.R.
0
@@ -357,278 +265,6 @@ if (PIR1bits.RCIF)
0
- case 'P': // comando PWM
0
- PWM1 = ((int) strcom[3] << 8) + (unsigned char) strcom[4];
0
- PWM2 = ((int) strcom[3] << 8) + (unsigned char) strcom[4];
0
- if (strcom[4] == '1') LATCbits.LATC0 = 1;
0
- else LATCbits.LATC0 = 0;
0
- if (strcom[4] == '1') LATCbits.LATC5 = 1;
0
- else LATCbits.LATC5 = 0;
0
- case 'G': // comando GPIO
0
- if (strcom[2] == 'R') // legge PORTB
0
- if (strcom[2] == 'W') // scrive su PORTB
0
- case 'M': // comando MD22
0
- MD22mod(strcom[3],strcom[4]);
0
- MD22(strcom[3],strcom[4],1);
0
- MD22(strcom[3],strcom[4],2);
0
- case 'I': // comando I2C write
0
- case 'L': // comando I2C read
0
- if (strcom[2] == '1') // ping
0
- if (strcom[2] == 'A') // change address
0
- SRF_Ad_Ch(strcom[3],strcom[4]);
0
- if (strcom[2] == '0') // legge
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- if (strcom[2]== 1) // CMPS03
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- if (strcom[2] == 'A') // change address
0
- CPMS03_Ad_Ch(strcom[3],strcom[4]);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- case 'S': // comando Servo
0
- S1 = ((int) strcom[3] << 8) + (unsigned char) strcom[4];
0
- S2 = ((int) strcom[3] << 8) + (unsigned char) strcom[4];
0
- S3 = ((int) strcom[3] << 8) + (unsigned char) strcom[4];
0
- S4 = ((int) strcom[3] << 8) + (unsigned char) strcom[4];
0
- S5 = ((int) strcom[3] << 8) + (unsigned char) strcom[4];
0
- S6 = ((int) strcom[3] << 8) + (unsigned char) strcom[4];
0
- S7 = ((int) strcom[3] << 8) + (unsigned char) strcom[4];
0
- S8 = ((int) strcom[3] << 8) + (unsigned char) strcom[4];
0
- case 'E': // Scrive EEPROM
0
- EEPROMWRITE(strcom[2] ,0x00);
0
- EEPROMWRITE(strcom[3] ,0x01);
0
- EEPROMWRITE(strcom[4] ,0x02);
0
- EEPROMWRITE(strcom[5] ,0x03);
0
- EEPROMWRITE(strcom[6] ,0x04);
0
- for (S1=0;S1<4;S1++) // fa lampeggiare il LED
0
- case 'Z': // Legge EEPROM
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
- TXREG = EEPROMREAD(0x00);
0
- while(!TXSTAbits.TRMT);
0
- TXREG = EEPROMREAD(0x01);
0
- while(!TXSTAbits.TRMT);
0
- TXREG = EEPROMREAD(0x02);
0
- while(!TXSTAbits.TRMT);
0
- TXREG = EEPROMREAD(0x03);
0
- while(!TXSTAbits.TRMT);
0
- TXREG = EEPROMREAD(0x04);
0
- while(!TXSTAbits.TRMT);
0
- while(!TXSTAbits.TRMT);
0
-for (i=0;i<10;i++) strcom[i] = 0;
0
void SRFping(unsigned char ADDS)
0
EEByteWrite(ADDS, 0x00, 0x51); // Start ranging, risultato in cm.
0
@@ -809,7 +445,8 @@ void init_sys(void)
0
- USART_BRGH_HIGH, tmp2);
0
+ USART_BRGH_HIGH, 1041);
0
+// USART_BRGH_HIGH, tmp2);
0
Con BRGH = 1, BRG = 16 (risoluzione a 16 bit)
Comments
No one has commented yet.