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.

Converting Mikro c code into HITECH C

Status
Not open for further replies.

7ezhil7

Junior Member level 2
Junior Member level 2
Joined
Mar 31, 2016
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
214
Hi,
I created a program in Mikro c which includes DHT11 sensor.The code got compiled sucessfully in Mikroc.I need to simulate in Proteus 8.1 which contains Hitech c compiler.I dont know how to convert that.So please help me to convert the code also correct any logic mistakes present in my code.
Thanks in advance.
Code:
                           // LCD module connections
sbit LCD_RS at RE2_bit;
sbit LCD_EN at RE0_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISE2_bit;
sbit LCD_EN_Direction at TRISE0_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
 // End LCD module connections
 char *text,mytext[4];
 unsigned char  a = 0, b = 0,i = 0,sum = 0, t1= 0,t2 = 0,rh1 = 0,rh2 = 0,rhout = 0,tempout = 0,tempin = 0, ws = 0,tempdiff = 0,t = 0;
 void out();void in();
 void ReadDataout();
 void ReadDatain();  void windspeed();


void out()
        {
              TRISA = 0b11111110;
                   
                    PORTA.F0 = 0;   
                     delay_ms(18);
                     PORTA.F0 = 1;  
                     delay_ms(30);
                     TRISA =0b00000001;    
                     delay_ms(40);    
                     a = 0;
                     delay_ms(40);
                     if (PORTA.F0 == 0)
                     {delay_us(80);
                     if (PORTE.F0 == 1)   a = 1;   delay_us(40);}

                     if(a == 1)
                   {
                       ReadDataout();
                       rh1=i;
                       ReadDataout();
                       rh2=i;
                       ReadDataout();
                       t1=i;
                       ReadDataout();
                       t2=i;
                       ReadDataout();
                       sum = i;
                       if(sum == rh1+rh2+t1+t2)
                             {rhout = rh1;
                             tempout = t1;
                             text = "TempOUT:  .0C";
                             Lcd_Out(1,1,text);
                             text = "HumiOUT:  .0%";
                             Lcd_Out(2,1,text);
                             ByteToStr(t1,mytext);
                             Lcd_Out(1,9,Ltrim(mytext));
                             ByteToStr(rh1,mytext);
                             Lcd_Out(2,9,Ltrim(mytext));

                             }
                          else
                               {
                               Lcd_Cmd(_LCD_CURSOR_OFF);        // cursor off
                               Lcd_Cmd(_LCD_CLEAR);             // clear LCD
                               text = "Checksumerror-out";
                               Lcd_Out(1,1,text);

                               }
                    }
       else
       {
       text="No response";
       Lcd_Out(1,1,text);
       text = "out";
       Lcd_Out(2,1,text);
       }
     delay_ms(2000);
  }

void ReadDataout()
 {
 for(b=0;b<8;b++)
 {
 while(!PORTA.F0); 
 delay_us(30);
 if(PORTA.F0 == 0)    i&=~(1<<(7-b));  //Clear bit (7-b)
 else
 {i|= (1<<(7-b));              
 while(PORTA.F0);
 }
 }
 }


 void in()
    {
 TRISA = 0b11111101;
   
 PORTA.F1 = 0;  
 delay_ms(18);
 PORTA.F1 = 1;  
 delay_ms(30);
 TRISA =0b00000010;
 delay_ms(40);  

 a = 0;
 delay_us(40);
 if (PORTA.F1 == 0){
 delay_us(80);
 if (PORTA.F1 == 1)   a = 1;   delay_us(40);}

 if(a == 1)
  {
  ReadDatain();
  rh1=i;
  ReadDatain();
  rh2=i;
  ReadDatain();
  t1=i;
  ReadDatain();
  t2=i;
  ReadDatain();
  sum = i;
  if(sum == rh1+rh2+t1+t2)
         {
               tempin = t1;
         text = "TempIN:  .0C";
         Lcd_Out(1,1,text);
         text = "HumiIN:  .0%";
         Lcd_Out(2,1,text);
         ByteToStr(t1,mytext);
         Lcd_Out(1,8,Ltrim(mytext));
         ByteToStr(rh1,mytext);
         Lcd_Out(2,8,Ltrim(mytext));
         }
  else
         {
         Lcd_Cmd(_LCD_CURSOR_OFF);        // cursor off
         Lcd_Cmd(_LCD_CLEAR);             // clear LCD
         text = "Checksumerror-in";
         Lcd_Out(1,1,text);

         }
      }
       else
       {
       text="No response";
       Lcd_Out(1,1,text);
       text = "in";
       Lcd_Out(2,1,text);

       }
     delay_ms(2000);
 }
   void ReadDatain()
 {
 for(b=0;b<8;b++)
 {
 while(!PORTA.F1);
 delay_us(30);
 if(PORTA.F1 == 0)    i&=~(1<<(7-b));  //Clear bit (7-b)
 else
 {i|= (1<<(7-b));  
 while(PORTA.F1);
 }
 }
 }


    void main()
 {
 TRISA=11000000;
 TRISC=0;PORTC=0;
 TRISB = 0;PORTB = 0;   //Configure PORTB as output
 TRISD=0;PORTD=0;  
 Lcd_Init();
 while(1)
            {
        Lcd_Cmd(_LCD_CURSOR_OFF);        // cursor off
        Lcd_Cmd(_LCD_CLEAR);

                       out();
                         in();
                         tempdiff = tempout-tempin;

                     if(tempdiff < 8 && (25 < rhout < 80))
                     {PORTC=1;}
               }
                            }
 

That same code gives error in Hiech c compiler...Whereas in mikroc it compiled sucessfully.In Proteus simulation I am using Hitech C compiler.Thatsy I need to convert my code to hitech c.Thank you for your response.
 

Hello! Is there any thing like "proteus using hitech c"? I used all previous version of proteus up to 7.8 with mikroc and it work. After the schematic of your project have been created, Try loading your hex file or object code to the proteus project. Good luck.
 

Thank you for your Reply Sir,I am using Proteus 8.1 in which I have integrated Hitech C as compilerinsted of default compiler.I have created my project in Mikroc which compiled successfully.When I copy & paste the same code in Proteus Source file.It gives lot of errors in source code while compiling.As you said I have also loaded my Hex file into the controller(PIC16F877a) of Proteus schematic.There is no response.Please tell me what I should do.
 

There are settings that has to do with C Compiler (COF) in proteus. My concern is that the software would not have been made to work with only one Compiler library. If you are unable to get through, visit labcenter electronics forum website.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top