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 support@ccsinfo.com

Simple testprogram needed, what's goining wrong the hardware

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







Simple testprogram needed, what's goining wrong the hardware
PostPosted: Thu May 01, 2003 8:48 am     Reply with quote

Hello there i am new to CCS and to PIC's in general.
I made a testboard and simple testsoftware, but whatever i try it just dont seem to work.
So now i dont know if the error is in the software or the hardware ....

Can annyone help me out and take a look at the C file i have written ?

I am using a PIC16F870 @20mHz

To program the PIC i use IC-prog version 1.05

I have 2 leds conected to the B port with 2 470 Ohm resistors.
The leds should go on for 1 sec and then go off for 1 sec.

here is the C file i have written:


#include "C:\Mijn documenten\CCS\test2.h"
#use standard_io(b)


void main() {


setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_psp(PSP_DISABLED);
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);



while (TRUE) {
SET_TRIS_B( 0x00 ); // use portb as an output



output_b (0xff);//make all pins on port B high
delay_ms(1000);
output_b(0);// make all pins on port B low
delay_ms(1000);
}

}



here is my header file



#include <16F870.h>
#use delay(clock=20000000)
#fuses hs,nowdt,noprotect,put,nowrt,nolvp





i hope someone can tell me what i am doiing wrong, beacause i dont know if it is a hardware or a software error.

thanx !!
___________________________
This message was ported from CCS's old forum
Original Post ID: 14117
R.J.Hamlett
Guest







Re: Simple testprogram needed, what's goining wrong the hard
PostPosted: Thu May 01, 2003 9:23 am     Reply with quote

:=Hello there i am new to CCS and to PIC's in general.
:=I made a testboard and simple testsoftware, but whatever i try it just dont seem to work.
:=So now i dont know if the error is in the software or the hardware ....
:=
:=Can annyone help me out and take a look at the C file i have written ?
:=
:=I am using a PIC16F870 @20mHz
:=
:=To program the PIC i use IC-prog version 1.05
:=
:=I have 2 leds conected to the B port with 2 470 Ohm resistors.
:=The leds should go on for 1 sec and then go off for 1 sec.
:=
:=here is the C file i have written:
:=
:=
:=#include "C:\Mijn documenten\CCS\test2.h"
:=#use standard_io(b)
:=
:=
:=void main() {
:=
:=
:= setup_adc_ports(NO_ANALOGS);
:= setup_adc(ADC_OFF);
:= setup_spi(FALSE);
:= setup_psp(PSP_DISABLED);
:= setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
:= setup_timer_1(T1_DISABLED);
:= setup_timer_2(T2_DISABLED,0,1);
:= setup_ccp1(CCP_OFF);
:=
:=
:=
:=while (TRUE) {
:=SET_TRIS_B( 0x00 ); // use portb as an output
:=
:=
:=
:= output_b (0xff);//make all pins on port B high
:= delay_ms(1000);
:= output_b(0);// make all pins on port B low
:= delay_ms(1000);
:= }
:=
:=}
:=
:=
:=
:=here is my header file
:=
:=
:=
:=#include <16F870.h>
:=#use delay(clock=20000000)
:=#fuses hs,nowdt,noprotect,put,nowrt,nolvp
:=
:=
:=
:=
:=
:=i hope someone can tell me what i am doiing wrong, beacause i dont know if it is a hardware or a software error.
:=
:=thanx !!
At a quick glance the code should function. There are a couple of 'errors', but nothing that would stop operation. The errors relate to the use of TRIS. Basically if you use 'standard_io', you don't have to control the TRIS register yourself. The compiler will automatically add TRIS instructions for you. Hence the 'set_tris_b' instruction is redundant. You will get (slightly) faster IO, if you instead #use fast_io(b). The placement of the TRIS is also in a sense 'wrong', you don't need to call this inside each loop. Set the port up once, and only make another call if you need to change it.
That having been said, these should not stop the code working. Hence the suspicion starts to point to a hardware problem. Obvious things to check are:
Have you got both Vss connections made?. Failure to connect both pins, can cause major problems.
Have you got a pull-up resistor on the MCLR connection?.
Can you check if your crystal is actually oscillating?. An oscilloscope onto pin10, should show the signal, and if this is not present, possibly suggests a programming problem (wrong oscillator type being for some reason selected - though you have if specified correctly in the code), or a problem with the chip.
Is the chip verifying OK in the programmer?.
Otherwise have a look at the errata sheet, where early date code chips are shipping with LVP enabled, which can prevent the chip from actually programming.
You have correctly avoided the most common errors (selecting NOLVP, and disabling the watchog).

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 14118
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