what is "IRP bit must be set manually,,," ??

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
a_7amasha
Posts: 2
Joined: 23 Jan 2012 18:22

what is "IRP bit must be set manually,,," ??

#1 Post by a_7amasha » 23 Jan 2012 18:34

Hi all, this is my first post here, and I'm a little bit beginner in using MikroC. so I'm using MikroC pro V.4.6, my project is connecting Pic16f877a with character LCD, the following code is working 100%

Code: Select all

// Lcd pinout settings
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;

// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;

float x,y,m,n,i=0; char txt[12];
char txt1[12];
int a=10;
void main()
{
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
TRISC=0;
TRISD=255;
portc.b0=0;
portc.b0=1;
Lcd_Out(1, 3, "Hello Ahmad !");
delay_ms(300);
portc.b0=0;
delay_ms(5000);
lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Temp=");
x=adc_read(0);
y=(x*500)/1024;
floattostr(y,txt);
lcd_out(1,6,txt);
lcd_chr_cp(223);
lcd_chr_cp('c');
if(y>=30)
{
 Lcd_Out(2, 1, "I think its hot");
  delay_ms(3000);
}
else
{

  Lcd_Out(2, 1, "I think its cold");
  delay_ms(3000);
}
if(portd.B0==1)
{
  lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1, 1, "no need to turn");
        Lcd_Out(2, 1, "on the lights");
    delay_ms(3000);
}
else
{
   lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1, 1, "Its better to");
    Lcd_Out(2, 1, "turn on the ligh");
    delay_ms(3000);
}
lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1, 1, "car will lock in");

    for(a=10;a>=0;a--)
    {
     inttostr(a,txt1);
     lcd_out(2,4,txt1);
     delay_ms(500);

    }
  lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1, 4, "car locked");


}

but when i added more lines to the code i got this error:
Image


this is how i connected the LCD to the PIC:

Image


I wanted to add While(1) loop as well many other commands,,,,,

so I dont know what's am I doing? or there is a problem in my compiler's version...

Help plz!

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Re: what is "IRP bit must be set manually,,," ??

#2 Post by pwdixon » 24 Jan 2012 09:56

you need to attach those images again as they are not visible and they do kind of define your problem.

Mince-n-Tatties
Posts: 2780
Joined: 25 Dec 2008 15:22
Location: Scotland

Re: what is "IRP bit must be set manually,,," ??

#3 Post by Mince-n-Tatties » 24 Jan 2012 10:04

a_7amasha wrote:Hi all, this is my first post here, and I'm a little bit beginner in using MikroC. so I'm using MikroC pro V.4.6, my project is connecting Pic16f877a with character LCD, the following code is working 100%

Code: Select all

// Lcd pinout settings
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;

// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;

float x,y,m,n,i=0; char txt[12];
char txt1[12];
int a=10;
void main()
{
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
TRISC=0;
TRISD=255;
portc.b0=0;
portc.b0=1;
Lcd_Out(1, 3, "Hello Ahmad !");
delay_ms(300);
portc.b0=0;
delay_ms(5000);
lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Temp=");
x=adc_read(0);
y=(x*500)/1024;
floattostr(y,txt);
lcd_out(1,6,txt);
lcd_chr_cp(223);
lcd_chr_cp('c');
if(y>=30)
{
 Lcd_Out(2, 1, "I think its hot");
  delay_ms(3000);
}
else
{

  Lcd_Out(2, 1, "I think its cold");
  delay_ms(3000);
}
if(portd.B0==1)
{
  lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1, 1, "no need to turn");
        Lcd_Out(2, 1, "on the lights");
    delay_ms(3000);
}
else
{
   lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1, 1, "Its better to");
    Lcd_Out(2, 1, "turn on the ligh");
    delay_ms(3000);
}
lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1, 1, "car will lock in");

    for(a=10;a>=0;a--)
    {
     inttostr(a,txt1);
     lcd_out(2,4,txt1);
     delay_ms(500);

    }
  lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1, 4, "car locked");


}

but when i added more lines to the code i got this error:
Image


this is how i connected the LCD to the PIC:

Image


I wanted to add While(1) loop as well many other commands,,,,,

so I dont know what's am I doing? or there is a problem in my compiler's version...

Help plz!
look here

http://www.mikroe.com/forum/viewtopic.p ... =ram+saver
Best Regards

Mince

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Re: what is "IRP bit must be set manually,,," ??

#4 Post by pwdixon » 24 Jan 2012 11:46

I managed to view the images by removing the extra '\' characters in the link.

I tried to reproduce your problem in MC V5.4 but I got a different error, "Identifier 'a' redefined", changing 'a' to a named variable eg 'Wibble' removed the error. I did not get any errors reated to the txt strings.

Mince-n-Tatties
Posts: 2780
Joined: 25 Dec 2008 15:22
Location: Scotland

Re: what is "IRP bit must be set manually,,," ??

#5 Post by Mince-n-Tatties » 24 Jan 2012 14:03

i can build the exact code pasted without getting any redef warning for variable a.

the only warning i see is the irp_bit, which is the result of having no RAM space available in bank0/1.

hint: 0 1139 Available RAM: 352 [bytes], Available ROM: 8192 [bytes]
diagnostics: 0 126 All files Preprocessed in 1 ms
diagnostics: 0 122 Compilation Started irp_bit_ram_issue.c
diagnostics: 79 123 Compiled Successfully irp_bit_ram_issue.c
diagnostics: 0 127 All files Compiled in 31 ms
warning: 17 1511 IRP bit must be set manually for indirect access to 'txt' variable irp_bit_ram_issue.c
warning: 18 1511 IRP bit must be set manually for indirect access to 'txt1' variable irp_bit_ram_issue.c

hint: 0 1144 Used RAM (bytes): 209 (59%) Free RAM (bytes): 143 (41%) Used RAM (bytes): 209 (59%) Free RAM (bytes): 143 (41%)
hint: 0 1144 Used ROM (program words): 2207 (27%) Free ROM (program words): 5985 (73%) Used ROM (program words): 2207 (27%) Free ROM (program words): 5985 (73%)
diagnostics: 0 125 Project Linked Successfully irp_bit_ram_issue.mcppi
hint: 0 1004 COFF file successfully generated COFF file successfully generated
diagnostics: 0 128 Linked in 484 ms
diagnostics: 0 129 Project 'irp_bit_ram_issue.mcppi' completed: 578 ms
diagnostics: 0 103 Finished successfully: 24 Jan 2012, 12:57:42 irp_bit_ram_issue.mcppi
Best Regards

Mince

Mince-n-Tatties
Posts: 2780
Joined: 25 Dec 2008 15:22
Location: Scotland

Re: what is "IRP bit must be set manually,,," ??

#6 Post by Mince-n-Tatties » 24 Jan 2012 14:21

applying the information available in the link i posted...

i was able to reduce the RAM usage to just 24%. hence no more irp_bit problem

hint: 0 1139 Available RAM: 352 [bytes], Available ROM: 8192 [bytes]
diagnostics: 0 126 All files Preprocessed in 16 ms
diagnostics: 0 122 Compilation Started irp_bit_ram_issue.c
diagnostics: 116 123 Compiled Successfully irp_bit_ram_issue.c
diagnostics: 0 127 All files Compiled in 15 ms
hint: 0 1144 Used RAM (bytes): 84 (24%) Free RAM (bytes): 268 (76%) Used RAM (bytes): 84 (24%) Free RAM (bytes): 268 (76%)
hint: 0 1144 Used ROM (program words): 2236 (27%) Free ROM (program words): 5956 (73%) Used ROM (program words): 2236 (27%) Free ROM (program words): 5956 (73%)
diagnostics: 0 125 Project Linked Successfully irp_bit_ram_issue.mcppi
hint: 0 1004 COFF file successfully generated COFF file successfully generated
diagnostics: 0 128 Linked in 500 ms
diagnostics: 0 129 Project 'irp_bit_ram_issue.mcppi' completed: 594 ms
diagnostics: 0 103 Finished successfully: 24 Jan 2012, 13:17:52 irp_bit_ram_issue.mcppi
Best Regards

Mince

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Re: what is "IRP bit must be set manually,,," ??

#7 Post by pwdixon » 24 Jan 2012 14:36

I included the txt variable and an inttostr(a,txt) in some other running code most certainly for a different (larger) processor so I didn't get the same error but where the redefinition error came from I don't yet know.

Mince-n-Tatties
Posts: 2780
Joined: 25 Dec 2008 15:22
Location: Scotland

Re: what is "IRP bit must be set manually,,," ??

#8 Post by Mince-n-Tatties » 24 Jan 2012 19:53

irp_bit is fairly well documented in the fourm and is most often related to LCD projects where several Menu screens or information screens are being used. I say most oftem LCD projects because the same would be true for projects with large array buffers etc. Basically any project that exceeds RAM banks 0 & 1 on a 16F pic while using any current version of mikroC will result in irp_bit problems.

The very easy answer is use pic 18F but that is not always an option for end users.
Best Regards

Mince

MARIO
Posts: 978
Joined: 18 Aug 2008 22:13
Location: Brasil

Re: what is "IRP bit must be set manually,,," ??

#9 Post by MARIO » 24 Jan 2012 22:41

So why not ME solve it?
I guess if the compiler can detect it, it can solve it too.
Non-pro version of MKC does it! :roll:
I am very confused as I didn't get a plausible answer when you have a function (like strcmp()) where you may have one string which needs IRP_bit set but the other string doesn't. :?
How can we solve it?
Would someone clarify it to me?

Thanks.

BR

Mince-n-Tatties
Posts: 2780
Joined: 25 Dec 2008 15:22
Location: Scotland

Re: what is "IRP bit must be set manually,,," ??

#10 Post by Mince-n-Tatties » 25 Jan 2012 10:26

force your arrays into the same RAM bank. keyword absolute.
Best Regards

Mince

MARIO
Posts: 978
Joined: 18 Aug 2008 22:13
Location: Brasil

Re: what is "IRP bit must be set manually,,," ??

#11 Post by MARIO » 25 Jan 2012 15:55

Thanks Mince.

But depending on the needs of the code, this is a kind of limitation. If compiler solves it, so there will be no limitation by the compiler, only by the device.

BR

a_7amasha
Posts: 2
Joined: 23 Jan 2012 18:22

Re: what is "IRP bit must be set manually,,," ??

#12 Post by a_7amasha » 25 Jan 2012 19:57

thanx all for replying! and I'll try to reduce the used RAM and see what happens,,,,

Post Reply

Return to “mikroC PRO for PIC General”