CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

question on PIC16F876

 
Post new topic   Reply to topic    CCS Forum Index -> CCS ICD / Mach X / Load-n-Go
View previous topic :: View next topic  
Author Message
microccd



Joined: 08 Aug 2006
Posts: 10

View user's profile Send private message

question on PIC16F876
PostPosted: Thu Aug 10, 2006 3:20 pm     Reply with quote

I am learning to program the microcontrollers, the following test code works fine on the 16F877 development kit. But it doesn't work on 16F876. Any help will be highly appreciated.

Code:

#include <16f876.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)

#define YELLOW_LED PIN_B4
#define RED_LED PIN_B5
#define PUSH_BUTTON PIN_A4

#define cutoff 128 //2.5 volts
#define neutral_zone 100 //2.0 volts
main() {
   int reading;
   int i;
   setup_adc_ports(RA0_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(0);

   output_high(PIN_B4);
   output_high(PIN_B5);

   while(true){
       reading = read_adc();
       if(reading>(cutoff-neutral_zone/2) && reading<(cutoff+neutral_zone/2))
         {
         output_high(PIN_B5);
         output_low(PIN_B4);
         i=1;
         }

       else
         {
         output_low(PIN_B5);
         output_high(PIN_B4);
         i=2;
         }
               
       if(i==2)
         {
         while(input(PUSH_BUTTON));
         delay_ms(50);
         while(!input(PUSH_BUTTON));
         }

  }
}

microccd



Joined: 08 Aug 2006
Posts: 10

View user's profile Send private message

PostPosted: Fri Aug 11, 2006 3:24 pm     Reply with quote

help please.
jspencer



Joined: 22 Dec 2003
Posts: 57
Location: Boise, ID USA

View user's profile Send private message

PostPosted: Fri Aug 11, 2006 4:18 pm     Reply with quote

It would be better if you posted this in the General CCS Discussion forum. Might try over there.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> CCS ICD / Mach X / Load-n-Go All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group