View previous topic :: View next topic |
Author |
Message |
hamid9543
Joined: 31 Jan 2013 Posts: 63
|
how create library |
Posted: Wed Jan 08, 2014 9:19 am |
|
|
Hi, how create library (.h file) in ccs compiler?
Thx |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19563
|
|
Posted: Wed Jan 08, 2014 9:36 am |
|
|
Type it......
.h files are just include files. Plain text. Can be edited with any text editor.
A genuine 'library' (.o file), is rarely used in CCS. The compile speed is so high, compared to the size of code that fits in most PIC's that 'pre-compiling' sections doesn't gain much, and unfortunately _reduces_ the ability to optimise RAM/ROM use, often resulting in larger final code, and less spare RAM. Since memory is normally a 'precious' resource on the PIC's this is best avoided.
You can generate a .o file, and an associated .h file, but then the answer is the same. Type it. You would need to generate a .c file that is compiled to generate the .o file, and definitions of the functions that go into the .h file.
Examples of this are with the compiler. In the 'examples' directory, there is a 'mcu.zip' file, that expands into a project showing the .c files for three parts, and the main file including the .h files and linking the pre-compiled sections.
Best Wishes |
|
|
hamid9543
Joined: 31 Jan 2013 Posts: 63
|
|
Posted: Wed Jan 08, 2014 10:12 am |
|
|
Hi. I think you couldn't undrestand what i mean. I want to creat a header in CCS. For example I have a hardware like a sensor or LCD then I try to build a library for them. Please give me a solution.
Thanks a lot. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9254 Location: Greensville,Ontario
|
|
Posted: Wed Jan 08, 2014 10:43 am |
|
|
comment: words mean different things to different people.
To me you want a 'driver'. A chunk of code designed to control/interface with a device or peripheral.An LCD module is a great example. I use the 'flex_LCD.C' code but have renamed it to my_flex_LCD.dvr.It is a copy of the original,modified to suit me, and the extension dotDVR designates it's a 'driver'.
I also have a pictype_fuses.fuz 'header' file to configure the fuses for a known PIC.ie: 46k22_fuses.fuz is my 'header' file with a set of known good fuses. As there are a LOT of fuse on modern PICs, it reduces the size of the project 'main' as well eliminates problems due to bad typing!
CCS does provide a LOT of 'drivers' for various internal and external peripherals. These are located in the 'drivers' folder.
hth
jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19563
|
|
Posted: Wed Jan 08, 2014 12:41 pm |
|
|
My answer stands. Type it....
This is a _help_ forum, not a 'write it for you' forum.
You need to start with the data sheet for the device. Then see if there are any other _similar_ devices. If there are, look in the CCS drivers (and here), and see if somebody has done it already, either for your device, or the similar device (code forum in particular).
Probably 75%+ of devices use similar interfaces. SPI, I2C, or simple shift and latch type interfaces. If so, then dozens (hundreds) of existing drivers will exist that you can use.
Once you get close, then we can/will help to spot the problems (hopefully), and point you towards a solution.
Best Wishes |
|
|
|