View previous topic :: View next topic |
Author |
Message |
Oznog
Joined: 16 Oct 2004 Posts: 6
|
Converting HiTech code to CCS |
Posted: Mon Oct 25, 2004 9:01 pm |
|
|
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
|
|
Posted: Tue Oct 26, 2004 3:54 am |
|
|
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
|
|
Posted: Tue Oct 26, 2004 9:00 am |
|
|
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
|
|
Posted: Tue Oct 26, 2004 11:08 am |
|
|
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:
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
|
|
Posted: Tue Oct 26, 2004 11:30 am |
|
|
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
|
|
Posted: Tue Oct 26, 2004 1:41 pm |
|
|
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?
Carlo |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|