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

a very basic code not working? 16F870

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
digitalfreak



Joined: 16 Feb 2005
Posts: 25

View user's profile Send private message

a very basic code not working? 16F870
PostPosted: Wed Feb 08, 2006 11:58 am     Reply with quote

I have used (Mplab, picstartplus, CCS c compiler) a while ago, now kind of of lost touch completely...please help what am I doing wrong?


Code:
#include <16f870.h>
#device adc=8
#use delay(clock= 4000000, restart_wdt)
#fuses NOWDT, XT, PUT, NOPROTECT, BROWNOUT, NOLVP, NOCPD, NOWRT
#include <math.h>

#use fast_io(A)
#use fast_io(B)
#use fast_io(C)

void main () {

  set_tris_a(0b00111110);
  set_tris_b(0b11111100);
  set_tris_c(0b00000000);         

  setup_adc(ADC_CLOCK_INTERNAL);
  setup_adc_ports(NO_ANALOGS);
 
  output_low(PIN_B1); 

  while (TRUE) {     
    output_high(PIN_B1);
    delay_ms(10);
  }
}



just to be sure

pin 1 - pulled high to vdd (5V) using 5.1K rresistor
8 and 19 - ground
9 and 10 - 4MHz crystal and 33pF caps as shown in data sheet
20 vdd(5V)

I couldnot see HIGH (5V) on PIN_B1 what the heck....

I have programmed before and made few working circuits, this is killing me...

what could go wrong?

thx
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Sat Feb 11, 2006 12:54 pm     Reply with quote

trying taking out...

Code:
set_tris_a(0b00111110);
  set_tris_b(0b11111100);
  set_tris_c(0b00000000);


and run it....??

Measure it again,,,

I ain't no expert..just a suggestion... Very Happy
Ttelmah
Guest







PostPosted: Sat Feb 11, 2006 4:20 pm     Reply with quote

The program as written should work.
He has fast_io selected, so needs the TRIS statements. B1, is correctly set as an output.
Realistically, at this point one would be looking for something faulty. A crystal not oscillating. A chip that is damaged. An IC socket that is not actually making good contact. A supply that is not quite good enough, triggering a brownout. Inadequate decoupling, causing the chip to reset.
What compiler version?. if old, there might be a problem here.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion 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