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

Output_float, input statements help...

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



Joined: 18 Oct 2006
Posts: 9

View user's profile Send private message

Output_float, input statements help...
PostPosted: Wed Oct 18, 2006 10:25 pm     Reply with quote

Guys or gals,

I need help with this little project.

I have the PIC16F877A chip and Im trying to read the values from some pins and low or high some other pins based from the input values.

I already checked that the values in the inputs were high (4.5 - 5V) at first (first if condition) and tried low (0V) (second if condition), and the outputs from the chip never change (always stay at 2.1 - 2.2V), in both situations.

What Am I doing wrong? Im a newbie in PIC C and I would like to get some guidance. Below is the code Im using...

#include "C:XXXX\AC.h"


void main()
{

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);

while (TRUE)
{
//output_float (PIN_D3);
//output_float (PIN_D7);
//output_float (PIN_D6);

if (input (PIN_D3) == 1 && input (PIN_D7) == 1 && input (PIN_D6) ==1)
{

output_high (PIN_D1);
output_high (PIN_D0);
output_high (PIN_A1);

}// end if statement

else if (input(PIN_D3) == 0 && input (PIN_D7) == 0 && input (PIN_D6) == 0)
{

output_low (PIN_D1);
output_low (PIN_D0);
output_low (PIN_A1);

}//end else

else
{

output_low (PIN_D1);
output_low (PIN_D0);
output_high (PIN_A1);

} //end second else

}// end while loop

}// end program
xcamarox



Joined: 18 Oct 2006
Posts: 9

View user's profile Send private message

PostPosted: Wed Oct 18, 2006 10:28 pm     Reply with quote

The .h file is as follows:

#include <16F877A.h>
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,RC, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, LVP, NOCPD, NOWRT


Is there anything wrong with this code? Obviously there is, because it does not work. Do I have to use the timer? CCCP? Anything?

Im really hoping for an answer.

Please reply at your earliest convinience.

TIA!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 18, 2006 11:09 pm     Reply with quote

Quote:

#include <16F877A.h>
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,RC, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, LVP, NOCPD, NOWRT



1. Are you really using an external RC oscillator circuit ?
The highest allowable frequency is 4.0 MHz. It won't run at 20 MHz.
To get a 4 MHz frequency, you have to use R-C values of about
3K for the resistor and 20 pF for the capacitor.

If you don't know what you really have (R-C circuit, crystal, or
external oscillator) see this thread. It has links to photos.
http://www.ccsinfo.com/forum/viewtopic.php?t=28558


2. Are you really using Low Voltage Programming mode ? To use
that mode, you need to have a home-made programmer such as
the "TLVP" programmer, that supports LVP mode.

If you're using a normal programmer, such as a Microchip ICD2,
CCS-ICD, CCS MachX, Warp-13a, PicStart-Plus, etc., then change
the fuse to NOLVP.
xcamarox



Joined: 18 Oct 2006
Posts: 9

View user's profile Send private message

PostPosted: Wed Oct 18, 2006 11:26 pm     Reply with quote

PCM Programmer, I could kiss you right now, but I guess I would hate it later so,


THANK YOU VERY MUCH!!!


That did it. No wonder I used to have mixed results when I used this chip back 2 motnhs ago. Some stupid settings made a huge difference. I guess next time I'll do some more research. I would not think that for such a small program this made a difference, but now I guess I'll be more careful next time.

THANK YOU. GRACIAS. DANKA. MERCI!!!

I really can not thank you enough.
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