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

Please help me?????

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



Joined: 03 Nov 2006
Posts: 16

View user's profile Send private message MSN Messenger

Please help me?????
PostPosted: Tue Mar 06, 2007 11:05 pm     Reply with quote

Hi, I am a beginner for c program and PIC. I really want to learn PIC and I don't mind to spend time and effort on it, but I have no idea how and where to start learning it. Actually, I bought a book called, Embedded C Programming and the Microchip PIC by Barnett Cox & O'Cull. I also bought a development tools from Mikroelektronika - EasyPIC 4. When I got those two stuff, I was so excited..... Razz

But after few experiments (examples from the tools) I tried to do, I really feel frustrated. Crying or Very sad
I have no idea what do the commands do like,
void interrupt() {
if (PIR1 & TMR2IF) {
i++ ;
PIR1 &= ~(1<<TMR2IF);
}
PORTB = 0xFF;
TRISB = 0;
PORTD = 0x00;
TRISD = 0;
T2CON = 0xFF;
TMR2 = 0;
PIE1 |= (1 << TMR2IE);
INTCON = 0xC0;

There is no enough explanation. Can you guys please please give me some comments on that? And actually, I like this online http://mikroe.com/en/books/picbook/0_Uvod.htmbook, but unfortunately,
it uses Basic instead of C.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 06, 2007 11:25 pm     Reply with quote

Do you have the CCS compiler ? If so, look at this page:
http://www.ccsinfo.com/content.php?page=compspecific
It shows a list of the CCS built-in functions. As a newbie, it's much
easier to use the CCS functions than to setup individual registers in
the PIC. That's why CCS is popular with colleges. It's easier for
students to use.

Here's a list of functions and drivers:
http://www.ccsinfo.com/devices.php?page=exlist
harrison_c



Joined: 03 Nov 2006
Posts: 16

View user's profile Send private message MSN Messenger

No explanation
PostPosted: Tue Mar 06, 2007 11:54 pm     Reply with quote

Thank you so much!

Yes, I am looking for something like that, http://www.ccsinfo.com/content.php?page=compspecific
but how come there is no explanation again!!!

I have another question....I am really wondering how you guys got started when you guys were beginner?????
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 07, 2007 12:02 am     Reply with quote

The explanation of the functions is in the manual. Download it here:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Mar 07, 2007 10:04 am     Reply with quote

Download any PIC datasheet from Microchip, for example the PIC16F88
http://ww1.microchip.com/downloads/en/DeviceDoc/30487c.pdf

Reading the Chapter 15 you will find the explanation of all this "strange" words.

if (PIR1 & TMR2IF)
PIR1 = PERIPHERAL INTERRUPT REGISTER
TMR2IF = TIMER2 INTERRUPT FLAG

Quote:

I have another question....I am really wondering how you guys got started when you guys were beginner?????

This is a nice question that surely has multiples and complex answer.
I propose you to open a new (off topic) thread with this question, it will be interesting
to know the folks answers.


Humberto
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Mar 07, 2007 12:37 pm     Reply with quote

Quote:
I have no idea what do the commands do like,
void interrupt() {
if (PIR1 & TMR2IF) {
i++ ;
PIR1 &= ~(1<<TMR2IF);
}
PORTB = 0xFF;
TRISB = 0;
PORTD = 0x00;
TRISD = 0;
T2CON = 0xFF;
TMR2 = 0;
PIE1 |= (1 << TMR2IE);
INTCON = 0xC0;



void interrupt() will usually be a routine that is executed when an interrupt has happened, ie. reception of a character on the serial port or a signal on a pin that is tied to some hardware, inside of the PIC, that indicates that it needs to be taken care of right now, something like that. The syntax #int_TIMER1, #int_RDA or #int_AD will always be placed on the line _before_ the routine. This tells the compiler that this is the routine to execute when Timer1's interrupt is flagged or the Receved Data Available interrupt tells us that there is something coming in on the serial port and so forth.

Terms like INTCON, T2CON or PIE1 are physical locations, within the PIC, that are a byte(8 bits) at specific locations. Somewhere at the beginning of the code there would have been declarations something like:

#byte T2CON = 0x12
#byte ADCON0 = 0x1F

These are registers that you can access (read or write) during the execution of your program. If you look up a spec. sheet on a PIC you will see these terms thoughout the document. Individual bits can be read or manipulated to control different parts of the PIC. The evaluation: if(PIR1 & TMR2IF) look at two bits, that have been defined earlier in the code, if they are both set to a '1' then the if() code is entered and excecuted. If either one of them were set to '0' then it would have skipped that code.

I would suggest you look at some _very_ simple code and try to get an understanding of what's going on before you try to do anything complex. It took me several days(or was it weeks) before I had a grasp of how things worked with this particular compiler.

Good luck and I hope you don't have a LCD screen because CRT's can handle the head banging better. Twisted Evil

Ronald
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