Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

compiler for c

Status
Not open for further replies.

Dr_Doggy

Well-Known Member
mostly i have been using GCGB compiler which is working fine so i am keeping it for my 10f-18f smaller pgm apps.
however i have been working on some code where GCGB isn't cutting it any longer so i need to switch to a c compiler, what is the easiest option here; is there a better one?



A)ihave mplab ide; which has worked with assembally code(which I dont know) demos. there is a way to set it up for c but i ran in to details. Maybe i just need a template file(for16f886)?

B) I have tried WIZ-C PRO and i got the first demo to run on simulator, but then nothing else again(i think i have the wrong file loaded in). saying that this software may be to complex for me to "crash start"..,, but i do like the notion of the simulator.

C) swordfish has been working for me but my code has exceeded demo, maybe its best to just blow the 200$ to get the full license?
 
I think Hi-Tech C is a popular choice, especially with MPLAB. It comes in lite mode for free and seems to work great. I personally use C18 Lite (from Microchip) because I only have 18F chips. Hi-Tech covers a huge range of processors, though, and it would definitely be worth looking into. You can find the download for the lite version at the bottom of **broken link removed** page.

I hope this helps!
Good luck
 
Last edited:
The easiest way is to use MPLAB. If you didn't install it during MPLAB installation, then you should find the Hi-Tech C Compiler at C:/Program Files (x86)/Microchip/picc-x.xx-win.exe, depending on your system.

Note that the included Hi-Tech C Compiler is suitable for PIC 10/12/16's only, you will need Microchip C18 for PIC18's. You will need Microchip PIC C30 for PIC24's and dsPIC's and Microchip C32 for PIC32's.

Then all you have to do is select the suitable C Compiler as your Tool Suite when starting a new project.
 
Last edited:
For 16 series devices I tend to use BoostC over HiTech C. The main reason is the price for the full version, $70 -v- $500. Both have free versions to try.

You may also want to look at BoostBasic as, although I haven't tried it, it's supposed to be similar to VB and therefore should be similar to Swordfish.

For 18 series I use C18 and BoostC.

Mike.
 
yup, i forgot to point that out, the code that needs to be extended is for an 18f, but my demoboard is 16f, I thought they would be similar enough that if i got one going the switch would be simple, my bad!

im just watching now 3v0 intro demo so i ll bbs with lots of ?'s !
 
WOW, so i got furthur than i though i would anyway! i got to 6min in to the demo, but when i build it says FAILED
"Error - Device not specified. Use /p option to specify a device."

i went in to configure/select device.... and my pic is selected there, also i believe i have copied the source file exactly


#pragma config OSC=INTIO67, WDT=OFF, LVP=OFF
#include <p18f4620.h>
void main (void)
{
}


right?
 
WOW, so i got furthur than i though i would anyway! i got to 6min in to the demo, but when i build it says FAILED
"Error - Device not specified. Use /p option to specify a device."

i went in to configure/select device.... and my pic is selected there, also i believe i have copied the source file exactly


#pragma config OSC=INTIO67, WDT=OFF, LVP=OFF
#include <p18f4620.h>
void main (void)
{
}


right?

Did you remember to add the p18f4620.h header file to your project?

What version of MPLAB are you using?

Some versions had an error that would not set it properly. You can fix this by doing the following:

Go to Project –> Build Options –> Project, and open the MPLINK Linker tab. Make sure the ‘Use Alternate Settings’ check box is checked, for this setup.

You should see something that looks like this:

/m”$(BINDIR_)$(TARGETBASE).map”/w/o”$(BINDIR_)$(TARGETBASE).cof”

You'll need to change this to:

/m”$(BINDIR_)$(TARGETBASE).map”/w/p18F4620/o”$(BINDIR_)$(TARGETBASE).cof”

Let me know if this doesn't work, and I'll do some more research.

Good luck!
 
Last edited:
Last edited:
OK everything seems to be working ok, however i am just having a simple problem with some of the basic switching functions; I understand that TRIS(A-E) sets up the port and that PORT(A-E) change the bit values out(i will stay digital for now); but is there a way to change a single bit? in GCGB i would just say: SET PORTD.3 ON; also how would i say: READ PORTB.2?
 
If your library doesn't define (structures for) bit fields you can define your own. Read this thread:
https://www.electro-tech-online.com/threads/c18-structure-for-bits.94878/

I like to use macros for bit access. Setting a bit for example:

Code:
#define sbi(port, bit) ((port) |= (1 << (bit)))

main()
{
/* Set bit 3 in Port B */
sbi(PORTB, 3);
}

Here is a full collection of my bit operation macros:

Code:
/* Bit operation macros */
#define sbi(b,n) (b |= (1<<n))            /* Set bit number n in byte b	*/
#define cbi(b,n) (b &= (~(1<<n)))         /* Clear bit number n in byte b	*/
#define fbi(b,n) (b ^= (1<<n))            /* Flip bit number n in byte b	*/

#define bit_is_set(b,n) (b & (1<<n))       /* Return nonzero if bit is set */
#define bit_is_clear(b,n) (!(b & (1<<n)))  /* Return nonzero if bit is clear */

#define wait_until_bit_is_set(b,n)   while(bit_is_clear(b,n)){}
#define wait_until_bit_is_clear(b,n) while(bit_is_set(b,n)){}
 
Last edited:
mostly i have been using GCGB compiler which is working fine so i am keeping it for my 10f-18f smaller pgm apps.
however i have been working on some code where GCGB isn't cutting it any longer so i need to switch to a c compiler, what is the easiest option here; is there a better one?
Out of curiosity, where do you encounter the roadblock? is it math functions? array size?, some other libraries? Any specific code that doesn't work?
 
OK everything seems to be working ok, however i am just having a simple problem with some of the basic switching functions; I understand that TRIS(A-E) sets up the port and that PORT(A-E) change the bit values out(i will stay digital for now); but is there a way to change a single bit? in GCGB i would just say: SET PORTD.3 ON; also how would i say: READ PORTB.2?

You can also use:

LATAbits.LATA0 = 1; to set a bit, or:

PORTAbits.RA0; to read a bit.
 
Status
Not open for further replies.

Latest threads

Back
Top