i want to make frequency counter using LCD

ErnieM

Joined Apr 24, 2011
8,415
It looks like lib1 is the library you are trying to create. Basically that looks good, you did much of it correctly, and extra credit for doing the #ifndef/#define preamble to the dot H you made.

What is missing is a project, and a workspace: when you start a new programming project you need to create a new one (or copy and paste one that's close). To create one go to the menu, hit Project | Project Wizard and follow the prompts from there. Don't worry about adding any files yet.

Once complete make sure the Project and Output are both visible. If not, check them in the View Menu. In the source code area you can add (right click) all the dot C files. Optionally you can add the dot H files under header, but this is only for convienence (so you can see them or search them).

(Just because a file appears in headers doesn't make it a part of the compile!)

Lastly, you need to put a "#include<p18cxxx.h>" in your code so ti works with the C18 compiler.

Project | Build Options | Project, Directories tab,include search path should include your C18 /h folder... mine is at "C:\Program Files\Microchip\mplabc18\v3.40\h"

I got your code to build successfully... and I probably left out a few steps on how I did that.
 

Thread Starter

ect_09

Joined May 6, 2012
180
Thank you sir..
sir i'm using HI TECH compiler now..because it has good comments to use..and last file was on this compiler.

i am making timer0 for 1o sec delay.

but code showing errors.
kindly check this..
 

Attachments

Thread Starter

ect_09

Joined May 6, 2012
180
Rich (BB code):
#include "timer0.h"

void timer0()
{
T0CON=0x87;
TMR0H=0x67;
TMR0L=0x6A;
TMR0ON=1;
TMR0IE=1;
GIE=1;
while(TMR0IF==0);
TMR0ON=0;
TMR0IF=0;
that is code..
 

ErnieM

Joined Apr 24, 2011
8,415
IN timer0.c, you need to:

#include<htc.h>
(this needs to be in each dot C file)

add the last ; to this line:
TMR0H=0x67

Then it should build, it did for me.
 

massimj

Joined May 5, 2013
14
My guess is that English is not your primary language. If you switch to Basic, and use a free download of Picbasic pro, it will have commands outlined in the manual for your LCD control. The LCD control is one of the many library commands embedded into the compiler. The web site will have an example of code writing to the LCD. They also have a very cheap student version of the software. There are so many examples for using PIC basic on the internet that you will be able to help yourself with a little web browsing on the correct key words. You are trying to do this the hard way, with no experience, try doing it the easy way.

Why are you using an 18F PIC, is there some reason you must use it? There are much cheaper and simpler PICs to use, but to be honest, LCD control is simple of any PIC. It only becomes tricky when you try to do it on an 8 pin pic.
Good luck friend, Joe
 

Thread Starter

ect_09

Joined May 6, 2012
180
sir code showing no error now.

but its not working..

i made calculations

4Mhz/4/256=3.906khz=256us

1MC=256us


delay=(65536-xx)*1MC
let say u want 10 sec


10sec=(65536-xx)*256*10^-6
39062=65536-xx
xx=65536-39062
xx=26474

766A its hex.

code stop here on PORTB=0x55;

but not running PORTB=0xAA after delay().
what i do??
 

massimj

Joined May 5, 2013
14
Error checking comes in various ways, and the best compilers will take the chip into consideration and not let you use features, and memory space that do not exist. You can make a lot of mistakes and still get a good compile.
 

ErnieM

Joined Apr 24, 2011
8,415
Why make a wheel when you can get one (for free!) that's already round?

Go get the Microchip Libraries for Applications download and install it. It's a pretty big file but well worth it.

There is a file there called "TimeDelay.c" that has a Delay10us() and DelayMs() functions. They adjust to the clock speed you use when you make a dot h file called "HardwareProfile.h" For delays all you need in that is:

#define GetInstructionClock() 4000000

or whatever your clock rate is. Get that number right and the delays come out very close.

That's lots of steps but worth the effort if you want to do any advanced work with PICs using lots of free code that works for many PICs.
 

Thread Starter

ect_09

Joined May 6, 2012
180
sir i download files from the link that you give in last post.
i downloaded 2 file that i mention in .jpg.

i think it does not contain library for delay...

kindly guide me how to use..
i told you last time that i am using HI TECH compiler..

it will work for HI TECH..??

and kindly guide me how to use this..
 

Attachments

Last edited:

ErnieM

Joined Apr 24, 2011
8,415
Heh... I was at work all day, and I don't blog from the office (at this job anyway).

Just installed HiTech C18... it's not working for me. Yet.

You want to find 18f458.cfgdata contained in the dat/cfgdata directory of the HTC installation directory. How to use the commands starts on page 86 of the "manual.pdf" document.

In MPLAB is you hit Configure | Configuration Bits you get an idea of what needs to be done. Be careful, there are some 10 different config registers to be set.
 

Thread Starter

ect_09

Joined May 6, 2012
180
kindly reply me for post# 29.. kindly check this..
its about library...i am.not enable yet to find library..kindly guise me in this way..
thanks...
 
Top