Justinho27
Newbie level 5
- Joined
- Apr 24, 2014
- Messages
- 9
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 55
Hello guys!
Im pretty green with microcontrollers and programming, but i need some help with finishing my study project.
So, im using PIC16F877. I have made program code with mikroC PRO, but at the moment program is to big for demo version. So, i want to transfer it from mikroC to MPLAB v8.92. But when im trying to compile it with MPLAB i got a lot of errors, lol. Its my first project, so dont judge me, lol.
Here is the code wich perfectly works with mikroC (except the fact that its too long, lol):
How can i make this code work on MPLAB? I mean, how can i get .hex file... Which toolsuite i have to use... HELP!
Any help will be very very appreciated!
- - - Updated - - -
Or just, can anybody tell me how to easily make .hex of this program? Im not making real project, just Proteus simulation. Thank you!
Im pretty green with microcontrollers and programming, but i need some help with finishing my study project.
So, im using PIC16F877. I have made program code with mikroC PRO, but at the moment program is to big for demo version. So, i want to transfer it from mikroC to MPLAB v8.92. But when im trying to compile it with MPLAB i got a lot of errors, lol. Its my first project, so dont judge me, lol.
Here is the code wich perfectly works with mikroC (except the fact that its too long, lol):
Code:
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
unsigned char ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7;
unsigned int adc_rd0, adc_rd1, adc_rd2, adc_rd3;
char *text, *text3, *text1, *text2;
long et0, et1, et2, et3, kg1, kg2;
void main() {
INTCON = 0;
ANSELH = 0;
Lcd_Init(); // LCD display initialization
Lcd_Cmd(_LCD_CURSOR_OFF); // LCD command (cursor off)
Lcd_Cmd(_LCD_CLEAR); // LCD command (clear LCD)
text = "Fuel Balance"; // Define the first message
Lcd_Out(1,1,text); // Write the first message in the first line
text = "System by J.P."; // Define the second message
Lcd_Out(2,1,text); // Define the first message
ADCON1 = 0x82; // A/D voltage reference is VCC
TRISA = 0xFF; // All port A pins are configured as inputs
Delay_ms(1);
Lcd_Cmd(_LCD_CLEAR);
text1 = "L/H:";
text2 = "R/H:";
Lcd_Cmd(_LCD_CLEAR);
while (1) {
Lcd_Out(1,1,text1);
Lcd_Out(2,1,text2);
adc_rd0 = ADC_Read(0);
adc_rd1 = ADC_Read(1);
adc_rd2 = ADC_Read(2);
adc_rd3 = ADC_Read(3);
et0 = (long)adc_rd0 * 1000;
et1 = (long)adc_rd1 * 1000;
et2 = (long)adc_rd2 * 1000;
et3 = (long)adc_rd3 * 1000;
et0 = et0 / 1023;
et1 = et1 / 1023;
et2 = et2 / 1023;
et3 = et3 / 1023;
et0 = et1 * 100 / et0;
et2 = et3 * 100 / et2;
kg1 = et0 * 4530 / 100;
kg2 = et2 * 4530 / 100;
ch4 = et0 / 100;
ch5 = et2 / 100;
ch6 = kg1 / 1000;
ch7 = kg2 / 1000;
Lcd_Out(1,15,"KG");
Lcd_Out(2,15,"KG");
Lcd_Chr(1,11,48+ch6);
ch6 = (kg1 / 100) % 10;
Lcd_Chr(1,12,48+ch6);
ch6 = (kg1 / 10) & 10;
Lcd_Chr(1,13,48+ch6);
ch6 = kg1 % 10;
Lcd_Chr(1,14,48+ch6);
Lcd_Chr(2,11,48+ch7);
ch7 = (kg2 / 100) % 10;
Lcd_Chr(2,12,48+ch7);
ch7 = (kg2 / 10) & 10;
Lcd_Chr(2,13,48+ch7);
ch7 = kg2 % 10;
Lcd_Chr(2,14,48+ch7);
if (et0 > 99)
{
Lcd_Out(1,6,"FULL");
}
if (99 > et0 & et0 > 10)
{
Lcd_Out(1,6," ");
ch4 = (et0 / 10) % 10;
Lcd_Chr(1,7,48+ch4);
ch4 = et0 % 10;
Lcd_Chr(1,8,48+ch4);
Lcd_Chr(1,9,'%');
}
if (et0 < 10)
{
Lcd_Out(1,6,"LOW!");
}
if (et2 > 99)
{
Lcd_Out(2,6,"FULL");
}
if (99 > et2 & et2 > 10)
{
Lcd_Out(2,6," ");
ch5 = (et2 / 10) % 10;
Lcd_Chr(2,7,48+ch5);
ch5 = et2 % 10;
Lcd_Chr(2,8,48+ch5);
Lcd_Chr(2,9,'%');
}
if (et2 < 10)
{
Lcd_Out(2,6,"LOW!");
}
/*Lcd_Chr(1,11,48+ch0);
Lcd_Chr_CP('.');
ch0 = (tlong0 / 100) % 10;
Lcd_Chr_CP(48+ch0);
ch0 = (tlong0 / 10) % 10;
Lcd_Chr_CP(48+ch0);
ch0 = tlong0 % 10;
Lcd_Chr_CP(48+ch0);
Lcd_Chr_CP('V'); */
Delay_ms(1);
}
}
How can i make this code work on MPLAB? I mean, how can i get .hex file... Which toolsuite i have to use... HELP!
Any help will be very very appreciated!
- - - Updated - - -
Or just, can anybody tell me how to easily make .hex of this program? Im not making real project, just Proteus simulation. Thank you!
Last edited by a moderator: