¿Qué tal?
Soy nuevo en este foro y busco ayuda para poder utilizar el timer0 del Pic 18f4550, estoy haciendo un programa en el cual busco contar en un tiempo de un segundo cuantas veces cambia el pulso.Estoy utilizando mikro c y la verdad llevo muy poco haciendo esto.
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End Lcd module connections
char conversion[8];
int i,pulso=0,potencia=0;
void main(){
PORTD=0;
trisD=1;
Lcd_Init();
// Initialize Lcd
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
while(1){
// Write text in first row
switch(portd){
case 0x14:{
TMR0=0;//aquie es donde quiero activar el timer y saber cuantos pulsos recibo en un segundo
delay_ms(1000);
TMR0=pulso;
potencia=((1)*(3.6))/pulso;
InttoStr(potencia,conversion);
LCD_cmd(_LCD_CLEAR);
LCD_Out(1,1,"potencia=");
LCD_Out(2,1,conversion);
delay_ms(2000);
break;}
case 0x24:{
TMR0=0;
delay_ms(1000);
potencia=((21.6)*(3.6))/pulso;
InttoStr(pulso,conversion);
LCD_cmd(_LCD_CLEAR);
LCD_Out(1,1,"potencia=");
LCD_Out(2,1,conversion);
delay_ms(2000);
break;
}
case 0x44:{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,txt4); // Write text in second row
Delay_ms(500);
break;
}
default:{
LCD_OUT(1,1,"elige una opcion:");
delay_ms(200);
for(i=8; i>1; i--)
{ // Move text to the left 7 times
LCD_Out(2,i-8," 1)1kh 2)21.6kh 3)1.8kh ");
delay_ms(100);
}
for(i=1; i<8; i++)
{ // Move text to the right 7 times
LCD_Out(2,i-8," 1)1kh 2)21.6kh 3)1.8kh ");
delay_ms(100);
}
}
}
}
}
como podran ver soy muy novato en la programacion, espero su ayuda
