Program run in ISIS but not in real hardwar

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
ratna555
Posts: 5
Joined: 08 Jul 2013 05:25

Program run in ISIS but not in real hardwar

#1 Post by ratna555 » 18 Mar 2014 09:03

Hi,
I have made a simple program (Hello World) it working in simulation (ISIS) but not in real hardware. I hope the problem is come from OSC setting but have no idea about it, i have connected the 8 Mhz XT in proper pin and connected. I am newer in this world request your help regarding that. Incase any additional help required please let me know.

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: Program run in ISIS but not in real hardwar

#2 Post by p.erasmus » 18 Mar 2014 09:41

How do you expect help if we can not se what you are doing?
post a screen print of your Configuration settings ,which microcontroller and you schematic then people can help you
we have no glass balll through which we can see what you are doing.
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

ratna555
Posts: 5
Joined: 08 Jul 2013 05:25

Re: Program run in ISIS but not in real hardwar

#3 Post by ratna555 » 06 Apr 2014 11:09

Hi i am using PIC18F4520 with 8 Mhz cristal for clocking, 74595, 4017 and 7seg-CC
it is run fine in Protious but not in real HW

Code: Select all

unsigned char key, flag, temp,temp1, dis_dig, next;
unsigned short value, i, val,j,bit_val[3];
unsigned int cnt,no[4],k,no1;
void find_ip()
{
 if(i==0)
 {
  if(temp==32)
  {value=1;}
  else if(temp==64)
  {value=2;}
  else if(temp==128)
  {value=3;}
 }
 if(i==1)
 {
  if(temp==32)
  {value=4;}
  else if(temp==64)
  {value=5;}
  else if(temp==128)
  {value=6;}
 }
 if(i==2)
 {
  if(temp==32)
  {value=7;}
  else if(temp==64)
  {value=8;}
  else if(temp==128)
  {value=9;}
 }
 if(i==3)
 {
  if(temp==32)
  {value=11;}
  else if(temp==64)
  {value=10;}
  else if(temp==128)
  {value=11;}
 }
}
void scan_row()
{
 switch(i)
 {
  case 0:
       PORTB.RB0=1;
  break;
  case 1:
       PORTB.RB1=1;
  break;
  case 2:
       PORTB.RB2=1;
  break;
  case 3:
       PORTB.RB3=1;
  break;
 }
}
void dec_cnvt(unsigned char vab)
{
 switch(vab)
 {
  case 10:
   dis_dig=0b00111111;
  break;
  case 1:
   dis_dig=0b00000011;
  break;
  case 2:
   dis_dig=0b01101101;
  break;
  case 3:
   dis_dig=0b01100111;
  break;
  case 4:
   dis_dig=0b01010011;
  break;
  case 5:
   dis_dig=0b01110110;
  break;
  case 6:
   dis_dig=0b01111110;
  break;
  case 7:
   dis_dig=0b00100011;
  break;
  case 8:
   dis_dig=0b01111111;
  break;
  case 9:
   dis_dig=0b01110111;
  break;
  case 0:
   dis_dig=0b00000000;
  break;
 }
}
void interrupt()
{
 if(INTCON.RBIF)
 {
  no1=no1+1;
  flag=3;
  temp=PORTB;
  INTCON.RBIF=0;
  temp=PORTB;
  //INTCON.RBIE=0;
//  no[0]=no1;
  if(no1>4)
  {
   no1=0;
   j=1;
  }
 }
 if(INTCON.TMR0IF)
 {
  cnt++;
  if(cnt>30)
  {
   key=1;
   cnt=0;
   dis_dig=0b00011011;
   INTCON=0b00001000;
   T0CON=0b00000110;
  // INTCON2.RBPU=0;
  }
  INTCON.TMR0IF=0;
  TMR0L=0x00;
  TMR0H=0xFF;
 }
 if(PIR1.SSPIF)
 {
  flag=2;
  PIR1.SSPIF=0;
 }
}
void main()
{
 OSCCON=0b11110110;
 INTCON=0b11101000;
 INTCON2=0b10000000;
 PIE1.SSPIE=1;
 T0CON=0b10000110;
 SSPSTAT.SMP=1;
 SSPSTAT.CKE=0;
 SSPCON1=0b00100001;
 TMR0L=0xD0;
 TMR0H=0xFF;
 TRISB=0xF0;
 PORTB=0x00;
 TRISC=0x10;
 PORTC=0x00;
 TRISD=0x00;
 while(1)
 {
  if(key==1)
  {
   key=0;
   for(i=0;i<4;i++)
   {
    scan_row();
    if(flag==3)
    {
     find_ip();
     j=no1/2;
    }
    PORTB.RB0=0;
   }
   INTCON=0b11100000;
   T0CON=0b10000110;
  }
  else if(key==0)
  {
   if(cnt>0)
   {
    bit_val[j]=value;
    val=bit_val[k];
    //val=j;
    PORTC.RC0=0;
    dec_cnvt(val);
    SSPBUF=dis_dig;
    if(flag==2)
    {
     while(dis_dig!=0)
     {
      dis_dig=dis_dig << 1;
     }
    }
    if(k==0)
    {PORTD=0b11111110;
    }
    if(k==1)
    {PORTD=0b11111101;
    }
    if(k==2)
    {PORTD=0b11111011;
    }
    k++;
    if(k>2)
    {k=0;}
    PORTC.RC0=1;
    //flag=0;
    delay_ms(2);
   }
  }
 }
}
Attachments
ckt.jpg
ckt.jpg (375.58 KiB) Viewed 1993 times

Acetronics
Posts: 715
Joined: 27 Dec 2006 14:33
Location: Le Tréport , FRANCE

Re: Program run in ISIS but not in real hardwar

#4 Post by Acetronics » 06 Apr 2014 17:57

project / edit project screen to fill ... :roll:

Alain

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: Program run in ISIS but not in real hardwar

#5 Post by petar.timotijevic » 07 Apr 2014 14:33

Hello,

Zip and attach project files in new post or attach screenshot of Project settings window.


Best regards,
Peter

ratna555
Posts: 5
Joined: 08 Jul 2013 05:25

Re: Program run in ISIS but not in real hardwar

#6 Post by ratna555 » 12 Apr 2014 09:43

Hi as per your requirement i update all, at this condition my circut is working but only one pin is lighted. Please Help me............
Attachments
Project window
Project window
Project window.jpg (355.36 KiB) Viewed 1942 times
Working_RBTEST.zip
Total files of this project
(41.14 KiB) Downloaded 94 times

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: Program run in ISIS but not in real hardwar

#7 Post by petar.timotijevic » 15 Apr 2014 05:05

Hello,

Please try code from attachment.


Best regards,
Peter
Attachments
Working_RBTEST.zip
(38.21 KiB) Downloaded 87 times

Post Reply

Return to “mikroC PRO for PIC General”