Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

hall'o i need help in my project( pic 16f877)

Status
Not open for further replies.

dohi

Junior Member level 3
Joined
Aug 8, 2011
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,457
hi
i have a c code and i want to compile it to hex form by micro c
and i wonder how can i do it ...
can any one help me
thanks

---------- Post added at 15:48 ---------- Previous post was at 15:39 ----------

/* Project: Digital Voltmeter based on PIC16F877
Oscillator @ 4MHz, MCLR Enabled, PWRT Enabled, WDT OFF

*/
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
0 sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
char Message1[] = "DVM Project";
unsigned int ADC_Value, DisplayVolt;
char *volt = "00.0";
void main() {
ADCON0 = 0 ; // Analog channel select @ AN0
ADCON1 = 0b00001110 ; // RA0/AN0 is analog input

TRISB = 0b00000000; // PORTB All Outputs
TRISA = 0b00000001; // PORTA All Outputs, Except RA0
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,Message1);
Lcd_Chr(2,10,'V'); do {
ADC_Value = ADC_Read(0);
DisplayVolt = ADC_Value * 2;
volt[0] = DisplayVolt/1000 + 48;
volt[1] = (DisplayVolt/100)%10 + 48;
volt[3] = (DisplayVolt/10)%10 + 48;
Lcd_Out(2,5,volt);
delay_ms(500); // Hold for 500 ms
} while(1);} // End main()
and you will find above the code in c..
 

hi
i have a c code and i want to compile it to hex form by micro c
and i wonder how can i do it ...
can any one help me
thanks

---------- Post added at 15:48 ---------- Previous post was at 15:39 ----------

/* Project: Digital Voltmeter based on PIC16F877
Oscillator @ 4MHz, MCLR Enabled, PWRT Enabled, WDT OFF

*/
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
0 sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
char Message1[] = "DVM Project";
unsigned int ADC_Value, DisplayVolt;
char *volt = "00.0";
void main() {
ADCON0 = 0 ; // Analog channel select @ AN0
ADCON1 = 0b00001110 ; // RA0/AN0 is analog input

TRISB = 0b00000000; // PORTB All Outputs
TRISA = 0b00000001; // PORTA All Outputs, Except RA0
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,Message1);
Lcd_Chr(2,10,'V'); do {
ADC_Value = ADC_Read(0);
DisplayVolt = ADC_Value * 2;
volt[0] = DisplayVolt/1000 + 48;
volt[1] = (DisplayVolt/100)%10 + 48;
volt[3] = (DisplayVolt/10)%10 + 48;
Lcd_Out(2,5,volt);
delay_ms(500); // Hold for 500 ms
} while(1);} // End main()
and you will find above the code in c..
hello dohi
just delete a zero at " 0 sbit LCD_D6_Direction at TRISB6_bit; " line. it should be" sbit LCD_D6_Direction at TRISB6_bit; " your code will work
 

are you having problem with the code or you dont actually know how to generate your hex file?open your mikroc and click on new project and use d wizard to creat a new project and make sure you can identify the directory of your project.copy and paste the code in d window and build d project.if there is no error go to d directory of your project you will see .hex file extensn there.And let us know if you have any error while compiling d code.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top