sbit sbit sbit sbit sbit sbit sbit sbit sbit sbit sbit sbit

LCD_RS LCD_EN LCD_D4 LCD_D5 LCD_D6 LCD_D7

at at at at at at

RD4_bit; RD5_bit; RD0_bit; RD1_bit; RD2_bit; RD3_bit; at at at at at at TRISD4_bit; TRISD5_bit; TRISD0_bit; TRISD1_bit; TRISD2_bit; TRISD3_bit;

LCD_RS_Direction LCD_EN_Direction LCD_D4_Direction LCD_D5_Direction LCD_D6_Direction LCD_D7_Direction

unsigned short current_duty, old_duty, current_duty1, old_duty1; unsigned frecuencia, pulso, conteo, revolucion; char cad[10]; char revolu[10]; void InitMain() { ADCON1 = 7; PORTA = 255; TRISA = 255; PORTD = 0; TRISD = 0; PORTC = 0; TRISC = 0; PWM1_Init(500); } void main() { { INTCON.F1 = 0; pulso++; if (pulso==1) {T1CON.F0=1;} else { T1CON.F0=0; INTCON=0; } } TRISB = 255; OPTION_REG = 0b0100000; INTCON=0b10010000; T1CON=0b00110000; Lcd_Init ( ); Lcd_Out(2,1, "Frecuencia :") ; Lcd_Out(1,1, "REV :"); TMR1H = TMR1L = 0; while(1) { if ( pulso == 2 ) { conteo = ( TMR1H<<8)+TMR1L; WordToStr ( conteo, cad); Lcd_Out (1,12,cad); LCD_Cmd(_LCD_CURSOR_OFF); frecuencia =(1000000/conteo)/8; WordToStr ( frecuencia, cad); Lcd_Out (2,12,cad); revolucon= 2*3.16*frecuencia; WordToStr ( revolucion, revolu); Lcd_Out (1,12,revolu); LCD_Cmd(_LCD_CURSOR_OFF); pulso = 0;

} Delay_ms(5). PWM1_Set_Duty(current_duty). current_duty++. } } . while (1) { if (RA0_bit) { Delay_ms(40). PWM1_Set_Duty(current_duty). PWM1_Set_Duty(current_duty). PWM1_Start(). current_duty--.TMR1H = TMR1L = 0. } InitMain(). current_duty = 32. } if (RA1_bit) { Delay_ms(40). INTCON = 0x90.

Sign up to vote on this title
UsefulNot useful