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.

New to C & MPLAB

Status
Not open for further replies.

Iawia

Member
Hi. I am learning assembly and C currently. I am using a PIC chip 12F508 as a starter. I did a few tutorials in assembly and now am working on my first C program. When I compile the 'hello world' program, I get an error using MPLAB v8.80:

Code:
Make: The target "D:\Master Documents\C Coding\Hello World 2.p1" is up to date.
HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode)  V9.83
Copyright (C) 2011 Microchip Technology Inc.
(1273) Omniscient Code Generation not available in Lite mode (warning)
Error   [800] C:\Users\HPDV7~1\AppData\Local\Temp\s4d8.; 324. undefined symbol "entry__putch"
********** Build failed! **********

The program is looking for something in the C:\ directory. Not sure what it is looking for, but I installed the program on the D:\ drive. Not sure if this is the problem, I am very new to MPLAB.

I added files 'stdio.h' to the 'header files' and the 'hello world.c' to the 'source files' in the project tree. do I need to add a linker file or some other files as well?

thanks,

-thomas
 
Last edited:
Hi. I am learning assembly and C currently. I am using a PIC chip 12F508 as a starter. When I compile the 'hello world' program, I get an error:

Code:
Make: The target "D:\Master Documents\C Coding\Hello World 2.p1" is up to date.
HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode)  V9.83
Copyright (C) 2011 Microchip Technology Inc.
(1273) Omniscient Code Generation not available in Lite mode (warning)
Error   [800] C:\Users\HPDV7~1\AppData\Local\Temp\s4d8.; 324. undefined symbol "entry__putch"
********** Build failed! **********

The program is looking for something in the C:\ Directory. Not sure what, but I installed the program on the D:\ drive. Not sure if this is the problem, I am very new to MPLAB.

I 'added files' stdio.h and the 'hello world.c' to the project. do I need to add a linker file?

thanks,

-thomas

Hi Thomas. It's only looking for certain program files in the C drive--not what you loaded there. Your problem is your symbol "entry_putch". You haven't defined it anywhere. It would help to see your code. You may have to include a header file--I'm not quite sure what "entry_putch" is supposed to be. Is that something that should be built into the language, or is that your own variable or constant (or command)?
If it's a variable, you need to declare it as an int or char.
 
I am trying to run the most famous of all programs, the 'hello world' routine. Here is the code below, the 'entry_putch' I really have no idea where it comes from as the source code itself has no variables.

Code:
#include<stdio.h>
main()
{
    printf("Hello World");
}
 
Last edited:
if i comment out printf("Hello World");
the code compiles successfully. So why is it not finding my printf(string) function? I have included the stdio.h header file.
 
Where do you think it will print "Hello World"? You can only use printf after you have written a putch routine.

Try blinking an LED instead.

Mike.
 
Where do you think it will print "Hello World"? You can only use printf after you have written a putch routine.

Try blinking an LED instead.

Mike.

I agree. You don't have an LCD. That "Hello World" program is usually intended for testing an LCD panel. Flashing an LED is the best way to learn the basics of programming a microcontroller, since you can connect one directly to a pin. It makes it much easier.
 
Last edited:
ok. i suppose you are right. it wouldn't make sense to use printf for the 12F508. is this really the reason why the code is not compiling? the compiler sees that the chip is not typically used for displaying print?

i only want to see MPLAB compile a program successfully with C so that I can begin learning the basics from tutorials.
 
ok. i suppose you are right. it wouldn't make sense to use printf for the 12F508. is this really the reason why the code is not compiling? the compiler sees that the chip is not typically used for displaying print?

i only want to see MPLAB compile a program successfully with C so that I can begin learning the basics from tutorials.

Yeah, that's probably your problem. The 12Fs seem kind of small to do anything with LCDs, so that particular phrase "entry_putch" probably isn't even in the stdio.h for the 12F. Blinking an LED is much easier and would be a better way to get used to it. You only have to set the TRIS settings and tell the ports to turn on, delay, then off. Very easy.
 
Thanks for your help guys! The standard 'light an LED' program is compiling and working on the chip. I still am wondering why printf doesn't work (printf calls 'entry_putch'). if i change the header files to include a larger chip then it should compile? i feel like it shouldn't matter. the printf function is clearly defined in the stdio.h header file. anyways perhaps i'll tackle that one another day! cheers everyone and have a merry christmas.
 
Last edited:
There is no way for the compiler to know how to write to anything unless you provide a putch routine.

From the HiTech manual,
3.13 Standard I/O Functions and Serial I/O
A number of the standard I/O functions are provided, specifically those functions intended to read
and write formatted text on standard output and input. A list of the available functions is in Table
3.12. More details of these functions can be found in Appendix A.
Before any characters can be written or read using these functions, the putch() and getch()
functions must be written.
Other routines which may be required include getche() and kbhit().

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top