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

Using PCM with ICD2 MPLAB6.13 and pic16F876A

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







Using PCM with ICD2 MPLAB6.13 and pic16F876A
PostPosted: Fri Mar 21, 2003 8:48 am     Reply with quote

Hi all
Im new with CCS Software I used to work with the High Tech Compiler. Can somebody tell me how to directly write to registers for example TRISB = 0;. Which header files must I include for this. Why can`t I programm (ICD2 PICDEm Plus Demo Board) my device out of MPLAB, which things must I fix before this works. Can somebody send me a working startup e.g. #include <pic.h> and so on?
Looking forward to your replies
Dietze
___________________________
This message was ported from CCS's old forum
Original Post ID: 12920
PCM programmer



Joined: 06 Sep 2003
Posts: 20559

View user's profile Send private message

Re: Using PCM with ICD2 MPLAB6.13 and pic16F876A
PostPosted: Fri Mar 21, 2003 11:27 am     Reply with quote

<font face="Courier New" size=-1>:=Hi all
:=Im new with CCS Software I used to work with the High Tech Compiler. Can somebody tell me how to directly write to registers for example TRISB = 0;. Which header files must I include for this. Why can`t I programm (ICD2 PICDEm Plus Demo Board) my device out of MPLAB, which things must I fix before this works. Can somebody send me a working startup e.g. #include <pic.h> and so on?
-----------------------------------------------------

In CCS, you use the #byte or #bit directives to define the
address of a register. This is in the manual. But here's
an example:

#byte TRISB_REG = 0x86

main()
{
TRISB_REG = 0x01; // Make Pin B0 be an input

while(1); // Prevent PIC from going to sleep
}

There are no header files provided by CCS that have all the
register definitions. The truth is, you really don't need
them. In Hi-Tech C, you have to do everything by hand.
To setup any peripheral, you have to use line after line
of register load statements. But in CCS, it's not necessary.
CCS has built-in functions to setup the peripherals.

Also, you probably think you have to set the Tris registers.
CCS has a mode called "standard i/o", which is the default.
If you use the CCS function such as output_low(), output_high(),
output_float(), etc., then CCS handles the TRIS automatically.

For example, in the program above, you could do this, instead:
output_float(PIN_B0);

In other words, most of the things that you had to do, to get
a Hi-Tech C program running, you don't have to do with CCS.
The compiler does it for you. You should welcome that.

Here is a sample program. To make it work with ICD,
I've followed the information in the CCS FAQ.
<a href="http://www.ccsinfo.com/faq/?27" TARGET="_blank"> <a href="http://www.ccsinfo.com/faq/?27" TARGET="_blank">http://www.ccsinfo.com/faq/?27</a></a>

Note: If you're running at a higher frequency than 4 MHz,
then change the XT to HS, and change the "clock=" statement
to show the proper speed.

#include "c:\Program Files\Picc\Devices\16F877.h"
#device ICD=TRUE
#fuses XT, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
#use Delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//====================================================

void main()
{
printf("Hello world\n\r");

while(1);
}

This program assumes you have pins C6 and C7 going to
a MAX232-type chip, which then goes to the PC's serial port.
It also assumes you're running a terminal program on your
PC, such as HyperTerminal, and that it's setup for 9600,N,8,1.
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12926
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