Besoin d'aide: Programme sous MikroC - C++ - Programmation
MarshPosté le 25-04-2014 à 19:37:47
salut j'ai un probleme concernant un programme sous MikroC for PIC 16f877 , dans le quel il y a un probleme de compilation avec la commande de l' ADC , il me donne des erreurs dans les lignes de ANSEL et ANSELH , voila mon programme au dessous :
sbit IR1 at RA3_bit; sbit IR2 at RA4_bit; sbit fan at RD2_bit; sbit BULB1 at RD3_bit; sbit BULB2 at RD4_bit; sbit LCD_RS at RB4_bit; sbit LCD_EN at RB5_bit; sbit LCD_D4 at RB0_bit; sbit LCD_D5 at RB1_bit; sbit LCD_D6 at RB2_bit; sbit LCD_D7 at RB3_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; char txt1[] = "TEMP "; char txt[10]; char txt3[] = "SMART"; char txt4[] = "LIBRERY"; char txt5[] = "FULL"; char txt6[] = "NOT"; char txt7[] = " "; char i; int cout; float tempc,mv1; void Move_Delay(){ Delay_ms(175); } float adcc(){ unsigned int temp_res; float lsb=5000.0/1024.0; float mv,tem,temp_h,temp_l; ANSEL=0*04; ANSELH=0; temp_res = ADC_Read(2); // Get 10-bit results of AD conversion temp_l= temp_res; // Send lower 8 bits to PORTB temp_h= temp_res >> 8; // Send 2 most significant bits to RC1, RC0 tem=256.0*temp_h+temp_l; mv=tem*lsb; // change to mv tempc=mv/10.0; return tempc; } float intens(){ float lsb=5000.0/1024.0; unsigned int inte_res; float inte_h,inte_l,inte; ANSEL=0*02; ANSELH=0; C1ON_bit = 0; // Disable comparators C2ON_bit = 0; TRISA=1; inte_res = ADC_Read(1); // Get 10-bit results of AD conversion inte_l= inte_res; // Send lower 8 bits to PORTB inte_h= inte_res >> 8; // Send 2 most significant bits to RC1, RC0 inte=256.0*inte_h+inte_l; mv1=inte*lsb; return mv1; } void revers(){ int v; v=0; while(v<10){ TRISB=0*00; PORTB=8; Delay_ms(20); PORTB=04; Delay_ms(20); PORTB=02; Delay_ms(20); PORTB=01; Delay_ms(15); v++; } }
Marsh Posté le 25-04-2014 à 19:37:47
salut j'ai un probleme concernant un programme sous MikroC for PIC 16f877 , dans le quel il y a un probleme de compilation avec la commande de l' ADC , il me donne des erreurs dans les lignes de ANSEL et ANSELH , voila mon programme au dessous :
sbit IR1 at RA3_bit;
sbit IR2 at RA4_bit;
sbit fan at RD2_bit;
sbit BULB1 at RD3_bit;
sbit BULB2 at RD4_bit;
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_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;
char txt1[] = "TEMP ";
char txt[10];
char txt3[] = "SMART";
char txt4[] = "LIBRERY";
char txt5[] = "FULL";
char txt6[] = "NOT";
char txt7[] = " ";
char i;
int cout;
float tempc,mv1;
void Move_Delay(){
Delay_ms(175);
}
float adcc(){
unsigned int temp_res;
float lsb=5000.0/1024.0;
float mv,tem,temp_h,temp_l;
ANSEL=0*04;
ANSELH=0;
temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
temp_l= temp_res; // Send lower 8 bits to PORTB
temp_h= temp_res >> 8; // Send 2 most significant bits to RC1, RC0
tem=256.0*temp_h+temp_l;
mv=tem*lsb; // change to mv
tempc=mv/10.0;
return tempc;
}
float intens(){
float lsb=5000.0/1024.0;
unsigned int inte_res;
float inte_h,inte_l,inte;
ANSEL=0*02;
ANSELH=0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
TRISA=1;
inte_res = ADC_Read(1); // Get 10-bit results of AD conversion
inte_l= inte_res; // Send lower 8 bits to PORTB
inte_h= inte_res >> 8; // Send 2 most significant bits to RC1, RC0
inte=256.0*inte_h+inte_l;
mv1=inte*lsb;
return mv1;
}
void revers(){
int v;
v=0;
while(v<10){
TRISB=0*00;
PORTB=8;
Delay_ms(20);
PORTB=04;
Delay_ms(20);
PORTB=02;
Delay_ms(20);
PORTB=01;
Delay_ms(15);
v++;
}
}
Merci d'avance