pic16f876 Program build error

Status
Not open for further replies.

madhu hegde

Junior Member level 3
Joined
Dec 11, 2009
Messages
30
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
india
Activity points
1,459
Hello All

I am facing problem with MPLAB IDE pic kit2. in that iam trying to build prog with 16f876 , but it is saying error , saying driver error .

My program attached , please any one help me generate HEX FILE .

...MADHU.

#include<16f876.h>
#DEVICE*=16 ICD=TRUE
#use Delay(Clock=20000000)
#use RS232(Baud=9600,Xmit=PIN_C6,Rcv=PIN_C7,brgh 1 ok)
float average_ad(byte chan){
int i,avg_num=32;
float avg=0,temp_avg=0;
set_adc_channel(chan);
delay_us(100);
for(i=1;i<=avg_num;++i){
avg+=read_adc();
delay_us(100);
}
return(avg/avg_num);
}
void pwm1_duty100(long pwm_percent,long pwm_maximum){
set_pwm1_duty((pwm_maximum/100)*pwm_percent);
}
main()
{
CONST float CHARGED=14.4;
CONST long NDELTA=-1;
CONST byte AMP_CHAN=0,BAMP_CHAN=3,BVOLT_CHAN=2,VOLT_CHAN=1;
float current,voltage,watts=0.0,old_watts=0.0;
float batamps,batvolts,batwatts;
float temp_watts,watts100,amp100,volt100;
long delta=1,pwm_max,pwm100;
long boost=0,boost_counter;
byte led_count=0;
output_low(PIN_C3);
setup_port_a(ALL_ANALOG);
setup_adc(adc_clock_div_32);
setup_timer_2(T2_DIV_BY_1,49,1);
setup_ccp1(CCP_PWM);
pwm_max=200;
pwm100=85;
pwm1_duty100(pwm100,pwm_max);
output_high(PIN_C3);
output_high(PIN_C0);
delay_ms(1000);
while(TRUE){
if(batvolts>CHARGED){
delta=NDELTA;
output_high(PIN_C5);
}
else if(old_watts>watts){
delta=-delta;
output_low(PIN_C5);
}
old_watts=watts;
pwm100+=delta;
if(pwm100>100)pwm100=100;
else if(pwm100<0)pwm100=0;
pwm1_duty100(pwm100,pwm_max);
current=average_ad(AMP_CHAN)/40.885;
voltage=average_ad(VOLT_CHAN)/18.2887;
batamps=average_ad(BAMP_CHAN)/41.3428;
batvolts=average_ad(BVOLT_CHAN)/20.4831;
watts=current*voltage;
batwatts=batamps*batvolts;
if((++boost_counter%20)==0){
pwm1_duty100(100,pwm_max);
delay_ms(20);
amp100=average_ad(AMP_CHAN)/40.885;
volt100=average_ad(VOLT_CHAN)/18.2887;
if(amp100<0.05){
output_high(PIN_C4);
output_low(PIN_C3);
delay_ms(1000);
}
watts100=amp100*volt100;
temp_watts=watts/watts100;
boost=(long)((temp_watts*100)-100);
}
printf("%lu%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%li%6.2f\r\n",pwm100,current,voltage,watts,batamps,batvolts,batwatts,boost,watts100);
output_bit(PIN_C0,(++led_count&0x01));
delay_ms(500);
}
}
 

You are getting error during compiling or during programming with PICKit2? What do you mean by driver error? Have you installed driver for PICKit2? Does MPLAB CCS C compiler generates .hex file? have you selected CCS C compiler as the tool for project? Have you installed CCS C MPLAB driver?
 


* yes ..i am getting this error during compiling ,

* after i pressed build option , this error appearing.

* no hex files are generates .

* yes i installed CCS C compiler as tool .but it is suitable to 16F876 i don,t know .

but still i am getting this .. but i am not much experience in this field . please help me .

or which tool is suitable to 16f876a give me the link ,,i will try .

madhu
 

Do you have a license for CCS C Compiler? Have you installed CCS C plugin? If not then downlaod proper plug-in from here and install it.

https://www.ccsinfo.com/downloads.php

There are 2 plug-ins, one for MPLAB and another for MPLABX.

Then read this...

https://www.ccsinfo.com/faq.php?page=ccs_mplab

See this video tut for MPLAB + CCS C

https://www.youtube.com/watch?v=BoPjqCjoULo

See this video for MPLABX + CCS C

https://www.youtube.com/watch?v=uziNEmDdF3g


I have used CCS C but not with MPLAB/X. Maybe you have to select some checkbox to get .hex file generated. See in build options or project properties.
 



Thank you .

i will try once again ..

thanks ...you .

madhu..
 

Thank you .

i will try once again ..

thanks ...you .

madhu..


Hello sir

i try to down load ..finally i am succeed . but tryed with my existing Soft ...but during build it showing error " No valid installed HI-TECH compiler drivers "

But i am heaving .MPLAB IDE V8.10 ' And also HI-TECH Software picc lite 9.60pl1.

what is the problem i am under standing please ..help me .

madhu.
 

The code you have posted in post #1 is for CCS C Compiler and not Hi-Tech C Compiler. MPLAB is an IDE. Download and install the latest version of MPLAB IDE which is 8.92. It is free. Download from Microchip. After that install the CCS C MPLAB driver from the link I gave earlier. Create New project and choose CCS C as the tool. Before this CCS C Compiler has to be installed on your system.

Zip and post your complete MPLAB + CCS C project files so that the project settings can be checked.


Try attached project.
 

Attachments

  • ADC.rar
    39.3 KB · Views: 33
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…