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

Converting HiTech code to CCS

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



Joined: 16 Oct 2004
Posts: 6

View user's profile Send private message

Converting HiTech code to CCS
PostPosted: Mon Oct 25, 2004 9:01 pm     Reply with quote

Is there a guide out for the shortest way to convert HiTech C code to CCS? I know the way of addressing pins and registers is different. I am unclear on how to even address registers from only a quick read of the CCS manual.

I have a large HiTech project for the PIC18F452 and would like to see how well CCS handles it.
Will Reeve



Joined: 30 Oct 2003
Posts: 209
Location: Norfolk, England

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Tue Oct 26, 2004 3:54 am     Reply with quote

I've not used the other compiler with PIC, but have a look under #byte and #bit for the register addressing.

Will
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Oct 26, 2004 9:00 am     Reply with quote

As a quick example.. in the 16F877 pdf manual serial port bits are defined.(pg. 100),.. and they can be used as follows
Code:

#include <16F877.h>
#device *=16
#include <string.h> //for memcmp
#bit RCIF=0x0C.5
#bit CREN=0x18.4
#bit OERR=0x18.1
#BYTE RCREG=0x1A
#CASE
#use delay(clock=16000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP
#define VER_MAJOR 1
#define VER_MINOR 00
#use rs232(baud=57600,xmit=PIN_A2,INVERT,stream=DEBUG)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,stream=FA403)

see how bit RCIF is defined as 0x0C bit 5.
and the byte of the recieve register is 0x1A.

Also take care if the location is a physical PIN. The TRIS needs to be set as IN or OUT. For this you are better off using x=input(PIN_B1); as this will set the tris for you
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Oct 26, 2004 11:08 am     Reply with quote

I never tried the High Tech compiler, but I guess it provides you with a header file defining all register names so you can write something like:
Code:
*T0CON = 0xC0;

The CCS compiler has a different philosophy where they try to hide the low register stuff from you and the same code becomes:
Code:
setup_timer_0( RTCC_INTERNAL | RTCC_8_BIT );

Very nice, but it doesn't make it easy to convert code from one compiler to the other.
Your High Tech code can still be used when you have a header file defining the register names. It would have been nice when CCS provided this file, but they don't. Considering you already own the High Tech compiler I suggest to copy the 18F452 header file provided by High Tech, otherwise have a look in this thread for two header files for the 18F452.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 26, 2004 11:30 am     Reply with quote

Quote:
otherwise have a look in this thread for two header files for the 18F452.

I didn't notice that you had actually linked to that thread until
after I went and found it (while intending to post it).
For some reason, this board didn't underline your 'this' link,
which made it hard to see (at least on my monitor).
http://www.ccsinfo.com/forum/viewtopic.php?t=14755
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Oct 26, 2004 1:41 pm     Reply with quote

Hi PCM!

I knew about that thread because I used it and converted the header file to the 18F458. Wow, did I have a lot of trouble searching the right keywords to find that thread again. Same with you? Smile
Carlo
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 26, 2004 1:55 pm     Reply with quote

Yes, so then I decided to search for 18F45x register names.
I looked in the data sheet and searched for INTCON INTCON2 INTCON3.
Then it popped up.
http://www.ccsinfo.com/forum/viewtopic.php?t=14755&highlight=intcon+intcon2+intcon3
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