LC meter coding problem - Page 1
Forum section: electronics / general

author: khatus
author_rank: Regular Contributor
timestamp: August 22, 2018, 04:13:00 pm
content: Hello,guys I have a code for LC meter using nokia 3310 display and PIC16F876A microcontroller. Which is written by some other person.The code is packed by winrar. When i extract the .rar file i have noticed that inside the folder there are three .c files and as well as three corresponding .h file. The three header files are1. "display.h" Which probably displays various values and to adjust screen.2. "lcd3310.h" which is for activate the lcd module3. "main.h" the main program.Now inside the main program the above 3 header file is mentioned.Like belowMy question is how does the program works?? and which file should be uploaded in to the micro controller??This time i wanted to use 0.96″ OLED I2C Display Module.And I have a code for this.But as per my knowledge the entire code should be inside just one .C file not like 3 mentioned above.My question is1. What will be the difference if i use 3 separate code instead of just one main program Which consist of three part ?2. If i write 3 individual code mentioned above then How can i join them and compiled them in to above??Please give a detailed advise as i am a programming beginner.

author: JS
author_rank: Frequent Contributor
timestamp: August 22, 2018, 04:24:22 pm
content: Inside the main.c you start including all H files, forget about all other C files, just have them there in the folder and the compiler will do the rest.JSPS: you should upload a .bin file to the uC, already compiled, not a C file.

author: ogden
author_rank: Super Contributor
timestamp: August 22, 2018, 04:37:07 pm
content: Quote from: khatus on August 22, 2018, 04:13:00 pmFirst advise: don't try to make ANY changes to the original design. Change of the display is not that easy as you say "I have code", definitely not for beginner of your level.There are MANY "PIC microcontroller for beginners" blogs, videos, books and so on. Code is compiled and loaded into chip similar way disregarding what it does - so start with some reading or watching videos.

author: khatus
author_rank: Regular Contributor
timestamp: August 22, 2018, 04:48:56 pm
content: I am using mikro c pro software for programming. definitely it requires some changes as the previous program is written in mplab. But till now i have never used multiple c files to to make one big program? I don't know what it's called?is this modular programming?? I wanted to about the programming structure ?? Do anyone have any link about this type of programming???

author: kripton2035
author_rank: Super Contributor
timestamp: August 22, 2018, 05:03:04 pm
content: it will be easier to download the free mplab IDE and compile with itmplab to mikroc conversion is all except easy ...

author: ogden
author_rank: Super Contributor
timestamp: August 22, 2018, 05:07:48 pm
content: Quote from: khatus on August 22, 2018, 04:48:56 pmIt's just programming.Mikro Cdoes support multiple source files per project. JustReadTheFunnyManual, check examples, check other projects made with your compiler/IDE. Do some research. Answers to your quite basic question about multiple files are all around the place (internet).

author: khatus
author_rank: Regular Contributor
timestamp: August 23, 2018, 03:27:36 am
content: So i can not use multiple source file for writing different part of the code.Does mplab supports multiple source files??I got this files fromhttp://projectproto.blogspot.com/2009/09/lc-meter-pic16f876a-n3310lcd.html.

author: kripton2035
author_rank: Super Contributor
timestamp: August 23, 2018, 06:27:30 am
content: use the hex file directly on this page :http://projectproto.blogspot.com/search?q=lcyou don't need to compile the source files (unless you need changes)but I would start with the already compiled and ready for you hex file.

author: MarkF
author_rank: Super Contributor
timestamp: August 23, 2018, 08:20:19 am
content: Quote from: khatus on August 23, 2018, 03:27:36 amSorry, I have never used Mikro C.But I would be surprised if you were able to find a compiler thatdoesn'tsupport multiple source files. Even assemblers I used in the 80's supported multiple source files.I personally use MPLAB X and the XC8 compiler for all my PIC software development. Andallof my projects have multiple source files.You can just download the two fromMicrochip. Install MPLAB X before XC8. Then create a new PIC16F876A project and add all your source files (*.c and *.h) to it. At a minimum, you will then need a PicKit 3 to write the .hex file from the "dist" directory within the project to your PIC.In the XC8 compiler all the PIC specific header files get added by including the "xc.h" file in your main.c or the main.h file since you have one.If you don't have it at the top of your main.c or main.h file, add a#include <xc.h>statement before all the other standard header include statements.Here's an example screenshot of a similar MPLAB project I did with a small OLED display. Note the included files in the left panel.

author: Ian.M
author_rank: Super Contributor
timestamp: August 23, 2018, 09:18:23 am
content: The source is written for HiTech C compiler for PIC10/12/16 v9.63. If you use HiTech C v9.83 (the final one) or any Microchip XC8 v1.xx version, you will have to define _LEGACY_HEADERS globally in the project options. XC8 v2.x is probably too new . . . .As the project is set up for MPLAB 8, and MPLAB X is notoriously bloated, *UNLESS* you want to move away from the MikroElektronika PIC toolchains to the current Microchip MPLAB X + XC ones, I see no benefit in downloading MPLAB X.Once you have a successful build, if you don't have a MPLAB compatible programmer, you can export the HEX file from MPLAB 8 and program it using MikroElektronika's standalone programming software.-----------------------------------------------------------As usual, the Microchip website is somewhat borked and legacy downloads are hard to reach, so here are some links to them:Seehttps://www.microchip.com/forums/FindPost/829198for how to get old HiTech compilers. Install it in FREE mode as it can no longer be licenced.The final MPLAB 8 release (before MPLAB X) is v8.92:http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_IDE_8_92.zipN.B. there's a patch to install XC8 v1.33 and newer versions for MPLAB v8.92. Seehttp://www.microchip.com/forums/FindPost/874217-----------------------------------------------------------Quote from: MarkF on August 23, 2018, 08:20:19 amThat would be CCS C. It was highly non-standard, definitely *NOT* ANSI C compliant and IIRC you had to #include all source files in a single C file as it didn't use a linker.

author: khatus
author_rank: Regular Contributor
timestamp: August 23, 2018, 01:30:52 pm
content: Is there will be any difference if i didn't use modular programming??

author: ogden
author_rank: Super Contributor
timestamp: August 23, 2018, 06:36:02 pm
content: Quote from: khatus on August 23, 2018, 01:30:52 pmNo. It's the same as to put different chapters of the book into different files - content does not change. You have smaller manageable files in case you want to edit them, especially if more than one people is working on various chapters. Usually bad things happen (some changes become lost) if two people edit same file at the same time. You see??