# [51]2 or more codes in keil with 8051

Status
Not open for further replies.

#### thexplanet

##### Newbie level 3
Hello All,

I am newbie, and learning 8051 with embeeded C,

i have a query to ask,

lets say, i have 3 different programs
1> LCD 16X2
3>Heart beat monitoring.

now i know they can be written in keil microvision software, but
I am confused, that when normally when we compile+link+obj+hex and burn the microcontroller with one HEX file,
now how to deal with 3 or more different programs.
each program is using different ports of 8051 (0,1,2 and 3)

can anyone pls clear my doubts.
Thanks,

#### andre_luis

##### Super Moderator
Staff member
You can load into core only one at a time.

+++

#### thexplanet

##### Newbie level 3
Thanks Andre_teprom,

Sir, which means, i will have to burn the same microcontroller chip, with 3 different HEX files 3 times, and it will function as the program is designed.
my 1st program is for display LCD 16X2 initialize and display, 2nd program is for reading temprature using ADC0808 via LM35, and 3rd is for heart beat using LDR and LED,
so in this case,
first i burn the hex file for 1st,
then burn the 2nd hex file
and then finally 3rd hex file, onto the same microcontroller 8051

is it right, am i interpreting it correctly?
Thanks

#### andre_luis

##### Super Moderator
Staff member
No, unless you compile them into a Real Time embedded OS, just one is allowable to run at a time, due you have just one core inside 8051.

+++

#### andre_luis

##### Super Moderator
Staff member
You need have a minimal knowledge about programing on C language to merge each piece on a unique main program.
The feature you are asking for is quite usual to achieve, but requires some time to perform simulations prior to run at core.

In other words, it´s simple, but tiresome.

+++

#### richardlaishram

##### Member level 4
From what I can understand is that, you have an LCD code, an ADC code and a Heart Beat Monitoring code which you want to load it as a whole program in the microcontroller, right?
I'm not sure if this is what you wanted: Make a new project, and in that save the LCD and ADC code as LCD.h and ADC.h and make the Heart Beat Monitoring code as the main function. And include the custom header files as shown below.
Code:
#include<reg51.h>
#include"LCD.h" // for custom header files <> cannot be used instead we've to use ""
#include"ADC.h"
Now you can all any functions declared in the ADC or LCD in your main function.

#### thexplanet

##### Newbie level 3
From what I can understand is that, you have an LCD code, an ADC code and a Heart Beat Monitoring code which you want to load it as a whole program in the microcontroller, right?
I'm not sure if this is what you wanted: Make a new project, and in that save the LCD and ADC code as LCD.h and ADC.h and make the Heart Beat Monitoring code as the main function. And include the custom header files as shown below.
Code:
#include<reg51.h>
#include"LCD.h" // for custom header files <> cannot be used instead we've to use ""
#include"ADC.h"
Now you can all any functions declared in the ADC or LCD in your main function.

Thanks richardlaishram
Thats Exactly I was looking for.

Thanks Andre_teprom

Status
Not open for further replies.