|
|
View previous topic :: View next topic |
Author |
Message |
digitalfreak
Joined: 16 Feb 2005 Posts: 25
|
a very basic code not working? 16F870 |
Posted: Wed Feb 08, 2006 11:58 am |
|
|
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
|
|
Posted: Sat Feb 11, 2006 12:54 pm |
|
|
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... |
|
|
Ttelmah Guest
|
|
Posted: Sat Feb 11, 2006 4:20 pm |
|
|
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 |
|
|
|
|
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
|