Discussion in "PIC Microcontroller Discussion" started by    rews    Nov 13, 2008.
Thu Nov 13 2008, 07:58 am
#1
Hello.
i work with PIC 16f877.
I use "PICbootPlus" to write to the PIC
Whenever i click 'write',it say "timeout of communication!"
So, if anyone can take a look at look at the code, it will be a great help.
Thanks.
#include <16F877a.h>

#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12
#define ADDRESS 0


unsigned int a, x, deltaA, prevA=0, peakA, prevDeltaA=-1;


int acceleration()
{
  set_adc_channel(0);
  delay_ms(10);
  x = read_adc();
  delay_ms(20);
  return x;
  //write_eeprom(i,value);
  //value = read_eeprom(i);
}

void main() {
   set_tris_b(0b00000000);//setting the port job.
   set_tris_c(0);
   set_tris_d(0);

   setup_port_a( ALL_ANALOG );
   setup_adc( ADC_CLOCK_INTERNAL );

   

   do
   {
	   a= acceleration();
	   printf("acceleration=%u \n",a);
	   deltaA = a-prevA;
	   if(deltaA<0 && prevDeltaA>
0){
		   peakA = prevA;
		   printf("peak acceleration=%u \n",peakA);
		   if(peakA<104){
			   output_high(PIN_C0);
			   output_low(PIN_C1);
			   output_low(PIN_C2);

		   }else if(peakA<109 && peakA>
=104){
			   output_high(PIN_C1);
			   output_low(PIN_C0);
			   output_low(PIN_C2);

		   }else if(peakA>
=109){
			   output_high(PIN_C2);
			   output_low(PIN_C1);
			   output_low(PIN_C0);
		   }

	   }
     	prevDeltaA = deltaA;
	   prevA=a;


   } while (1);

}

Thu Nov 13 2008, 10:53 am
#2
PicBoot+ is a bootloader,right?
Do you have the bootcode written to your 877?
It's only after you write the bootloader code to your PIC,that you may use PicBootPlus for writing your hex files.
If you have succesfully written hex files using PicBootPlus before,then the error you're getting is because the serial communication between your pc and the pic is not ok.
So check your serial cable and it's connections to both the pc and the pic board.
After hitting 'write' you would need to reset your PIC.hope you are doing that.
 rews like this.
Thu Nov 13 2008, 01:22 pm
#3
[Admin: Topic moved to PIC Microcontroller Discussion]

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Clydehet
Wed May 01 2024, 06:44 pm
Davidoried
Wed May 01 2024, 06:11 pm
KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am