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

PIC16F877A programming

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







PIC16F877A programming
PostPosted: Wed Mar 04, 2009 5:58 pm     Reply with quote

hi ,

I am trying to program a PIC16F877A.

I just started using it and am just testing the program.

Mmy program is simply:
Code:

#include<16....>

#byte port_c = 7


void main{

   set_tris_c(0);
   port_c = 0;
   byte value;
   value = 0x00;

   while(TRUE){
   
   port_c = value;

   }

}

Basically this thing does nothing except to set port_c into output and put all output as 0.

But when I test the output it doesn't give me the 0 V I was looking for.

Can someone explain why?

Thanks for your help
nostep



Joined: 04 Mar 2009
Posts: 16

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 6:24 pm     Reply with quote

What are you getting as an output?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 6:28 pm     Reply with quote

Quote:
#include<16....>

#byte port_c = 7

void main{

set_tris_c(0);
port_c = 0;
byte value;
value = 0x00;

while(TRUE){

port_c = value;

}

}

I tried to compile this with vs. 4.087, but it won't compile.
CCS doesn't permit variables to be declared in the middle of code.
You need to move it to the start of main(). What version are you using ?
noob_programmer
Guest







sorry
PostPosted: Wed Mar 04, 2009 6:49 pm     Reply with quote

Sorry i didn't type it exactly like my code.

My intention was to say that

I tried to program it like that but my output measured by the oscilloscope gives me 2.5V out(which is neither here nor there).

the only stuff which i did was:
Code:
#byte port_c = 7
void main(){

    port_c = 0;
   
    while(TRUE){

        //nothing important.
       DELAY_MS(1000);

    }


}

Also I have another question.
I see online codes.
They have #byte port_a = 5 port_b=6?
Is there a specific code for this ?
Where do I get all these code ?
noob_programmer
Guest







PostPosted: Wed Mar 04, 2009 6:50 pm     Reply with quote

i forgot to add that i have set_tris_c(0) for output as well.

i'm using 2 computers and using another computer for the programming and this to surf the web.


so i am handtyping everything again.
sorry for the confusion.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 6:58 pm     Reply with quote

Use CCS functions. They will set the TRIS correctly and do the job.

Code:
void main()
{

output_c(0x00);


while(1);
}
noob_programmer
Guest







PostPosted: Wed Mar 04, 2009 7:19 pm     Reply with quote

this is my exact code
Code:

#include <16F877A.h>
#USE DELAY (CLOCK=4000000)

#FUSES XT, NOWDT, NOPROTECT, NOPUT

void main(){

   output_c(0xff);
   while(1)


}




nope
the output is still not 1 like what i wanted
thanks for helping
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 7:33 pm     Reply with quote

1. Always use the NOLVP fuse.

2. What is your compiler version ?

3. What board is your code being tested on ? Did you build it yourself
or did you buy it ? If you bought it, post the manufacturer and part
number.
noob_programmer
Guest







PostPosted: Wed Mar 04, 2009 9:58 pm     Reply with quote

Thanks for your help.
I managed to solve it.

I have another question right now.
Does anyone know what is the return value of get_rtcc()?

It says on the CCS manual returns the count value of the clock.

But what does it mean?
Is it measured in seconds? Or the oscillator count value?
I'm trying to time the return pulse my sensor is giving me.
viknes1985



Joined: 11 Nov 2008
Posts: 24

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

it would be clock counter
PostPosted: Thu Mar 05, 2009 2:45 am     Reply with quote

it would return oscillator counter.

for timer 0 (rtcc) : 0 - 255
Sydney



Joined: 13 Feb 2009
Posts: 71

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 3:38 am     Reply with quote

noob_programmer wrote:
It says on the CCS manual returns the count value of the clock.


Read the microchip data sheet too Smile
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