Joined: 06 Sep 2003
|Re: Using PCM with ICD2 MPLAB6.13 and pic16F876A
|Posted: Fri Mar 21, 2003 11:27 am
|<font face="Courier New" size=-1>:=Hi all
:=I´m 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
#byte TRISB_REG = 0x86
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:
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"
#fuses XT, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
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.
This message was ported from CCS's old forum
Original Post ID: 12926