IRP bit must be set manually for indirect access to '?Loca
-
- Posts: 2780
- Joined: 25 Dec 2008 15:22
- Location: Scotland
Re: IRP bit must be set manually for indirect access to '?Lo
the forum is packed with help on this issue. there truly is no need for anyone to be stuck with this. all it takes is to use the search tool.
http://www.mikroe.com/app/webroot/forum ... ilit=saver
http://www.mikroe.com/app/webroot/forum ... ilit=saver
http://www.mikroe.com/app/webroot/forum ... ilit=saver
http://www.mikroe.com/app/webroot/forum ... ilit=saver
Best Regards
Mince
Mince
Re: IRP bit must be set manually for indirect access to '?Lo
Use this code for LCD Data, IRP problem will gone...
void Lcd_COut(char row, char col, const char *cptr)
{
char chr = 0; //first, it is used as empty string
Lcd_Out(row, col, &chr); //nothing to write but set position.
for ( ; chr = *cptr ; ++cptr ) Lcd_Chr_CP(chr); //out in loop
}
write in code...
Lcd_Cout(1,1,"Text");
void Lcd_COut(char row, char col, const char *cptr)
{
char chr = 0; //first, it is used as empty string
Lcd_Out(row, col, &chr); //nothing to write but set position.
for ( ; chr = *cptr ; ++cptr ) Lcd_Chr_CP(chr); //out in loop
}
write in code...
Lcd_Cout(1,1,"Text");
Re:
Hello,igor.stancic wrote:Hi,
You have a memory bank problem.IRP is bank select bit used for indirect
addressing.Our compiler is not capable to set IRP bit.
IRP=0 -> Bank 0,1
IRP=1 -> Bank 2,3
So you must do that manually. Also you can use 'absolute' directive and
move variable at memory banks 0 and 1(directive absolute specifies the starting address in RAM for variable.
If variable is multi-byte, higher bytes will be stored at the consecutive
locations).
Instead PIC16F you can always use PIC18F.
That way, you will not have any problems with memory banks.
Regards
Igor
I created a project with a pic16f883, it works well. Adding the functions, however, the space for the program was no longer well enough are so passed to a pic 16f886. Here, however, I had problems with the compiler regarding the addressing of RAM when the variables are no longer in Bank 0 and 1 and you need to set the bit maualmente IRP.
I do not know how I can set the flag if I want, for example, to sum two variables that are stored in two different banks, for example bank0 and bank3.
Can you make me an example?
Thanks,
Salvatore
example:
dim T_read as integer[10] ' bank 3
dim t_middle as integer 'default, bank 0/1
...
t_middle = t_middle + T_read
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: IRP bit must be set manually for indirect access to '?Lo
Hi,
You can switch from one bank to another using IRP and RP bits.
I suggest to take a look at this topic related to the memory access:
http://forum.mikroe.com/viewtopic.php?f ... ss#p212944
And datasheet for this MCU page 22:
http://ww1.microchip.com/downloads/en/D ... 41291D.pdf
Kind regards,
Aleksandar
You can switch from one bank to another using IRP and RP bits.
I suggest to take a look at this topic related to the memory access:
http://forum.mikroe.com/viewtopic.php?f ... ss#p212944
And datasheet for this MCU page 22:
http://ww1.microchip.com/downloads/en/D ... 41291D.pdf
Kind regards,
Aleksandar
Re: Re:
salvatore wrote:
I do not know how I can set the flag if I want, for example, to sum two variables that are stored in two different banks, for example bank0 and bank3.
example:
dim T_read as integer[10] ' bank 3
dim t_middle as integer 'default, bank 0/1
...
t_middle = t_middle + T_read
Thanks for your answer,
but my problem is that I have to do a sum of two variables that are stored in two different banks. Is there a solution to add these two variable value stored in different banks or I have to change the file structure in order to have the variables to sum in the same bank?
Example:
"buffer_seriale" in Bank 3 (absolute 0x120)
"Str_tmp" in Bank 0 (normal declaration)
buffer_seriale ="Ub1 "
ByteToStr(RH_Byte1, Str_tmp)
buffer_seriale = buffer_seriale + Str_tmp + ","
UART1_Write_Text(buffer_seriale)
When compiled, the compiler show these messages:
0 1519 IRP bit must be set manually for indirect access to '???addstrings_temp_legge_sensoreDHT' variable .mbas
209 1519 IRP bit must be set manually for indirect access to 'dato_letto' variable DOTI_883BT.mbas
0 1519 IRP bit must be set manually for indirect access to '?LocalText_LeggeBT' variable .mbas
211 1519 IRP bit must be set manually for indirect access to 'risultato_str' variable DOTI_883BT.mbas
0 1519 IRP bit must be set manually for indirect access to '???addstrings_temp_LeggeBT' variable .mbas
0 1519 IRP bit must be set manually for indirect access to '?LocalText_main' variable .mbas
it give warning on two variables (red) only, and is not clear the means of the others lines (1519, is the end of program...); not all the absolute variables have a warning and then to know if bank 0 and 1 are filled I must manually counts the bytes used... Is right?
I hope to have explained better my question.
Thanks a lot in advance,
Salvatore
PS Now I want to solve and well undestand this "characteristic"; in the next project the PIC will be 18F...
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: IRP bit must be set manually for indirect access to '?Lo
Hi,
Can you please attach me your project which you are trying to compile?
As I said, if you want to access some specific Bank you have to set RP bit.
I was not able to see that you have changed RP bit while accessing different Banks.
Kind regards,
Aleksandar
Can you please attach me your project which you are trying to compile?
As I said, if you want to access some specific Bank you have to set RP bit.
I was not able to see that you have changed RP bit while accessing different Banks.
Kind regards,
Aleksandar
Re: IRP bit must be set manually for indirect access to '?Lo
Hi!
This is an extract of the program that doesn't work:
program bank0123
'PIC 16F886 8MHz
'Interrupt: 1ms, LED display handling
'UART: BT module
Symbol display = PortB
Symbol colonna_display = PortA
Symbol tic = flag.0
dim dato_letto as string[23] absolute 0x130 '<------------------
dim shifter, port_index, flag, durata as byte
dim dato_display as byte[5] ' il valore dei 4 display + 5° display di simboli
dim nms as word ' per orologio di scansione display
dim visualizzazione_simboli as byte ' variabile x impostazione simboli sul dispaly (8) o su 5a cifra (16)
'Timer1
'Prescaler 1:1; TMR1 Preload = 63536; Actual Interrupt Time : 1 ms
sub procedure InitTimer1()
T1CON = 0x01
TMR1IF_bit = 0
TMR1H = 0xF8
TMR1L = 0x30
TMR1IE_bit = 1
INTCON = 0xC0
end sub
sub procedure Interrupt()
if (TMR1IF_bit) then
TMR1IF_bit = 0
TMR1H = 0xF8
TMR1L = 0x30
Inc (nms)
if (nms = 237) or (nms = 0) then
tic = not tic
end if
if nms >= 475 then
nms = 0
Inc(durata)
end if
colonna_display = 0
display = 0
delay_us(10)
colonna_display = shifter
display = dato_display[port_index]
Inc(port_index)
shifter = shifter << 1
if (shifter > visualizzazione_simboli) then
shifter = 1
port_index = 0
end if
end if
end sub
sub Procedure LeggeBT()
status.IRP = 1 '<------------------
if (UART1_Data_Ready() = 1) then
UART1_Read_Text(dato_letto, "OK", 23)
UART1_Write_Text(dato_letto) 'ECO to sender
end if
status.IRP = 0 '<------------------
end sub
main:
ANSEL = 0x10
ANSELH = 0
C1ON_bit = 0
C2ON_bit = 0
port_index = 0
shifter = 1
TRISA = 240
PORTA = 15
PortB = 0
TrisB = 0
TRISC.1 = 1
TRISC.2 = 0
TRISC.3 = 0
TRISC.4 = 0
TRISC.5 = 0
TRISC.6 = 0
TRISC.7 = 1
InitTimer1()
OSCCON.6 = 1
OSCCON.5 = 1
OSCCON.4 = 1
OSCTUNE = 4
UART1_Init(9600)
delay_ms(200)
UART1_Write_Text("Start!")
nms = 0
flag = 0
while TRUE
LeggeBT()
wend
end.
Thanks in advance,
Salvatore
This is an extract of the program that doesn't work:
program bank0123
'PIC 16F886 8MHz
'Interrupt: 1ms, LED display handling
'UART: BT module
Symbol display = PortB
Symbol colonna_display = PortA
Symbol tic = flag.0
dim dato_letto as string[23] absolute 0x130 '<------------------
dim shifter, port_index, flag, durata as byte
dim dato_display as byte[5] ' il valore dei 4 display + 5° display di simboli
dim nms as word ' per orologio di scansione display
dim visualizzazione_simboli as byte ' variabile x impostazione simboli sul dispaly (8) o su 5a cifra (16)
'Timer1
'Prescaler 1:1; TMR1 Preload = 63536; Actual Interrupt Time : 1 ms
sub procedure InitTimer1()
T1CON = 0x01
TMR1IF_bit = 0
TMR1H = 0xF8
TMR1L = 0x30
TMR1IE_bit = 1
INTCON = 0xC0
end sub
sub procedure Interrupt()
if (TMR1IF_bit) then
TMR1IF_bit = 0
TMR1H = 0xF8
TMR1L = 0x30
Inc (nms)
if (nms = 237) or (nms = 0) then
tic = not tic
end if
if nms >= 475 then
nms = 0
Inc(durata)
end if
colonna_display = 0
display = 0
delay_us(10)
colonna_display = shifter
display = dato_display[port_index]
Inc(port_index)
shifter = shifter << 1
if (shifter > visualizzazione_simboli) then
shifter = 1
port_index = 0
end if
end if
end sub
sub Procedure LeggeBT()
status.IRP = 1 '<------------------
if (UART1_Data_Ready() = 1) then
UART1_Read_Text(dato_letto, "OK", 23)
UART1_Write_Text(dato_letto) 'ECO to sender
end if
status.IRP = 0 '<------------------
end sub
main:
ANSEL = 0x10
ANSELH = 0
C1ON_bit = 0
C2ON_bit = 0
port_index = 0
shifter = 1
TRISA = 240
PORTA = 15
PortB = 0
TrisB = 0
TRISC.1 = 1
TRISC.2 = 0
TRISC.3 = 0
TRISC.4 = 0
TRISC.5 = 0
TRISC.6 = 0
TRISC.7 = 1
InitTimer1()
OSCCON.6 = 1
OSCCON.5 = 1
OSCCON.4 = 1
OSCTUNE = 4
UART1_Init(9600)
delay_ms(200)
UART1_Write_Text("Start!")
nms = 0
flag = 0
while TRUE
LeggeBT()
wend
end.
Thanks in advance,
Salvatore
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: IRP bit must be set manually for indirect access to '?Lo
Hi,
I have tried the example which you send and I didn't have any problem with compiling.
Here is the code for indirectly reading the variables from the different banks:
Kind regards,
Aleksandar
I have tried the example which you send and I didn't have any problem with compiling.
Here is the code for indirectly reading the variables from the different banks:
Code: Select all
program bank
'PIC 16F887 8MHz
'Interrupt: 1ms, LED display handling
'UART: BT module
dim variable1 as word absolute 0x20 ' write to bank 0 address
dim variable2 as word absolute 0x130 ' write to bank 3 address
dim a,b as byte
dim x as byte
main:
variable1 = 3 ' write value 0x39 to the address 0x20
variable2 = 7 ' write value 0x81 to the address 130
while(1)
IRP_bit = 0 ' set IRP bit to read from bank 0 and 1
FSR = 0x20 ' set pointer to the address 0x20
a = FSRPTR^ ' read pointed location
IRP_bit = 1 ' set IRP bit to read from bank 2 and 3
FSR = 0x30 ' set pointer to the address 0x130
b = FSRPTR^ ' read pointed location
x = a+b
wend
end.
Aleksandar
Re: IRP bit must be set manually for indirect access to '?Lo
Thanks for the reply,salvatore wrote:
if (UART1_Data_Ready() = 1) then
UART1_Read_Text(dato_letto, "OK", 23)
UART1_Write_Text(dato_letto) 'ECO to sender
end if
I understand how to operate, even if the method is more suitable for the assembler that not for a high-level language (I am surprised that it has never been implemented this directive since I have found posts 2008 which was already talking about this issue ... it is a great compiler limit).
That said, how can I develop UART routine that receives and retransmits what he has received (see above)? How do I handle the receive buffer with pointers? Is this possible or this buffers must be on 0 and 1 banks?
Thanks in advance,
Salvatore
PS my previous post have not errors, but it does not work!
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: IRP bit must be set manually for indirect access to '?Lo
Hi,
I have manage to store the data received from the UART as a byte to the bank 2 and send it back.
But had problem with the strings. I will try to investigate this a little bit more to see how this could be done.
Kind regards,
Aleksandar
I have manage to store the data received from the UART as a byte to the bank 2 and send it back.
But had problem with the strings. I will try to investigate this a little bit more to see how this could be done.
Kind regards,
Aleksandar
Re: IRP bit must be set manually for indirect access to '?Lo
OK, thanks.
Salvatore
Salvatore
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: IRP bit must be set manually for indirect access to '?Lo
Hi Salvadore,
I have manage to send string from the terminal and receive it back.
Unfortunately I was able to successfully send only 8 characters (8bytes):
"mikroeOK"
Declaration for the string which I was using is:
Kind regards,
Aleksandar
I have manage to send string from the terminal and receive it back.
Unfortunately I was able to successfully send only 8 characters (8bytes):
"mikroeOK"
Declaration for the string which I was using is:
Code: Select all
char uart_rd[10] absolute 0x130;
Aleksandar
Re: IRP bit must be set manually for indirect access to '?Lo
Sorry this is a old post but I was facing the problem so searched and reached here. I used your code and now I can write to the lcd but have two problems.MKDas wrote: ↑01 Dec 2015 17:24Use this code for LCD Data, IRP problem will gone...
void Lcd_COut(char row, char col, const char *cptr)
{
char chr = 0; //first, it is used as empty string
Lcd_Out(row, col, &chr); //nothing to write but set position.
for ( ; chr = *cptr ; ++cptr ) Lcd_Chr_CP(chr); //out in loop
}
write in code...
Lcd_Cout(1,1,"Text");
Now indirect access is pointing to chr at char chr=0; and second there is always a percentage sign if the start of the text.
How to rectify these issues?