OsvaldoH
Starting Member
- Total Posts : 88
- Reward points : 0
- Joined: 2012/11/24 12:49:19
- Location: 0
- Status: offline
Migrating from PIC16F1825 to PIC18F26Q10
I have a long program in assembler working with 16F1825 As I will need more pins , more EEPROMM and hardware multiplication, I found a low cost , new model 18F26Q10 I have installed MPLABX V5.3 and it is working ok in my PC with WindowsXP Please let me know if there is some some information that may help about this migration process. -------------------------------------------------------------- About pic18 intructions. For many instructions , there are ,d ,a but there are marked as optional { } ADDWF ADD W to f Syntax: ADDWF f {,d {,a}} I know that if not ",d" present , assembler place a 1 (dest. = f) ( for 16Fxxx ) May it be similar with ",a" ? I can´t find any about it in the datasheet RAM access bit (page 626) a = 0: RAM location in Access RAM (BSR register is ignored) a = 1: RAM bank is specified by BSR register Example 32-1 for A/D in assembler, page 557 , there is not any " ,a" BANKSEL ADCON1 clrf ADCON1 clrf ADCON2 I will apreciate any help Regards, Osvaldo Hojvat
post edited by OsvaldoH - 2020/12/05 09:10:55
|
Antipodean
Super Member
- Total Posts : 1984
- Reward points : 0
- Joined: 2008/12/09 10:19:08
- Location: Didcot, United Kingdom
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 11:48:00
(permalink)
OsvaldoH I have installed MPLABX V5.3 and it is working ok in my PC with WindowsXP Is there a reason why you installed v5.3 instead of v5.45?
Do not use my alias in your message body when replying, your message will disappear ... Alan
|
upand_at_them
Super Member
- Total Posts : 765
- Reward points : 0
- Joined: 2005/05/16 07:02:38
- Location: Pennsylvania
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 12:32:15
(permalink)
OsvaldoH About pic18 intructions. For many instructions , there are ,d ,a but there are marked as optional { } ADDWF ADD W to f Syntax: ADDWF f {,d {,a}} I know that if not ",d" present , assembler place a 0 (dest. = W) ( for 16Fxxx ) May it be similar with ",a" ? I can´t find any about it in the datasheet
Because it is the compiler that decides what values to use when you leave them blank. If you're using assembly you might check in the assembly user's guide?
|
upand_at_them
Super Member
- Total Posts : 765
- Reward points : 0
- Joined: 2005/05/16 07:02:38
- Location: Pennsylvania
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 12:42:38
(permalink)
|
1and0
Access is Denied
- Total Posts : 11747
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 13:00:46
(permalink)
☄ Helpfulby OsvaldoH 2020/12/04 16:16:06
OsvaldoH About pic18 intructions. For many instructions , there are ,d ,a but there are marked as optional { } ADDWF ADD W to f Syntax: ADDWF f {,d {,a}} I know that if not ",d" present , assembler place a 0 (dest. = W) ( for 16Fxxx )
When the ",d" field is not present, it will default to ",1" meaning the destination is ",f" (the file register itself) for both PIC16 and PIC18. May it be similar with ",a" ? I can´t find any about it in the datasheet
When the ",a" field is not present, MPASM will select the correct RAM access bit based on the address of the file register; i.e. if the file register is located in Access RAM it will be ",0" for ACCESS, else it will be ",1" for BANKED.
|
Mysil
Super Member
- Total Posts : 4062
- Reward points : 0
- Joined: 2012/07/01 04:19:50
- Location: Norway
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 13:05:04
(permalink)
☄ Helpfulby OsvaldoH 2020/12/05 09:16:33
Hi, Memory organisation is somewhat different in PIC18... microcontrollers from PIC16... devices. Memory organization is described in Memory organization chapter of the datasheet. In PIC16 devices, each memory bank is 128 bytes, of which 12 are Core CPU registers, 20 are SFR registers, and 16 are Common RAM memory bytes that can be reached regardless of Bank selection. But this only leave 80 bytes of general data memory RAM in each bank. In PIC18 devices, each bank is a full 256 bytes, and with the extra Access bank bit in each instruction, there is a total of 512 memory or register bytes that may be reached, without changing bank selection. Of those, 40 core CPU registers are reached in access bank, as well as 120 other SFR registers in access bank. Then there are 96 bytes of general RAM memory (from bank 0) that may be reached the same way. If your program code is well-behaved, and always do banksel instruction for the register to be used next, then none of this may matter, and you may probably ignore the access {,a} bit in instructions. movf register, w movwf register and other instructions that use W as accumulator, will probably work as you are used to. Also literal instructions like: movlw konstant; will function as usual, they do not have the a bit anyway. If you have code that speculate in using Common RAM without bank selection in PIC16, then you may have to consider using the access bit. Or if code use Core CPU registers without bank selection, then maybe the assembler may help you. These differences are general for all PIC18 devices, not just the new __Q10 family, so probably have been discussed in migration documents for other devices, and in this forum before. Mysil
|
OsvaldoH
Starting Member
- Total Posts : 88
- Reward points : 0
- Joined: 2012/11/24 12:49:19
- Location: 0
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 17:46:36
(permalink)
I was not sure if new versions works with Windows XP Perhaps V5.45 also works, but I only need Pic18F26Q10 was included I downloaded first 5.2 and have an error I have a slow notebook with W10 but I prefer to use my old PC with Wndows XP Regards, Osvaldo hojvat
|
OsvaldoH
Starting Member
- Total Posts : 88
- Reward points : 0
- Joined: 2012/11/24 12:49:19
- Location: 0
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 18:08:41
(permalink)
Thank you very much, it is exactly what I was asking In the MPLABX help I can´t find it I have only 2 days reading this data sheet and found a lot of diferences whith Pic16F1825 and F1826. Anyway it may be very usefull if in the datasheets be stated this information (default = 1) I know about the ",d" matter and I after several troubles I always state: ,w or ,f It will be easy to understand. Regards, Osvaldo Hojvat
|
OsvaldoH
Starting Member
- Total Posts : 88
- Reward points : 0
- Joined: 2012/11/24 12:49:19
- Location: 0
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 18:14:14
(permalink)
Thank you for your reply And for correct my wrong statement about ,d And because I am not sure,(don't remember it) I always state: ,w or ,f regards, Osvaldo Hojvat
|
OsvaldoH
Starting Member
- Total Posts : 88
- Reward points : 0
- Joined: 2012/11/24 12:49:19
- Location: 0
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:01:13
(permalink)
Thank you for your reply I will look for other pic18F migration docs. I was looking at the examples in the data sheet abou the use of ,a and because it tis optional I become confused. I think in the datasheet explanation, at the begining of instruccion set, page626 in the description of ,d and ,a it will be very usefull to sate that they are default = 1 I tryed to compile my code for 16F1825 and after new configuration bits , the second instruction movlp 0 - do not exists - gives error ( and a lot of other errors, of course) I think that I can forget the limit of 2k pages in the 16F1825 ROM - please confirm movlb is ok , is the same brw do not exists Regards, Osvaldo Hojvat
|
ric
Super Member
- Total Posts : 29435
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: online
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:05:16
(permalink)
OsvaldoH Anyway it may be very usefull if in the datasheets be stated this information (default = 1)
That is NOT a feature of the PIC instruction set. The "default" is set by the assembler "MPASM/MPASMX", so you need to read the user guide for the assembler, not the datasheet for the PIC to learn what the default is.
To get a useful answer, always state which PIC you are using!
|
1and0
Access is Denied
- Total Posts : 11747
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:19:05
(permalink)
OsvaldoH Anyway it may be very usefull if in the datasheets be stated this information (default = 1)
It is. See the image in Post #4 which is printed in some PIC16/18 datasheets. I know about the ",d" matter and I after several troubles I always state: ,w or ,f It will be easy to understand.
Most people prefer to explicitly write it, except me. ;)
|
1and0
Access is Denied
- Total Posts : 11747
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:25:00
(permalink)
OsvaldoH I tryed to compile my code for 16F1825 and after new configuration bits , the second instruction movlp 0 - do not exists - gives error ( and a lot of other errors, of course) I think that I can forget the limit of 2k pages in the 16F1825 ROM - please confirm movlb is ok , is the same brw do not exists
PIC16F1825 and all other enhanced mid-range PIC devices have those three instructions, so I don't know what you're talking about. <edit> Oh, are you referring to the PIC18? If so, the PIC18 devices do not have the MOVLP and BRW instructions. MOVLP is useless on a PIC18 because it has no concept of a program memory page; i.e. CALL and GOTO can address a 2-Mbyte program memory space.
post edited by 1and0 - 2020/12/02 19:32:37
|
ric
Super Member
- Total Posts : 29435
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: online
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:26:36
(permalink)
I think he is referring to reassembling his old PIC16F1825 code for PIC18F26Q10, so saying those instructions don't exist in PIC18 instruction set.
To get a useful answer, always state which PIC you are using!
|
1and0
Access is Denied
- Total Posts : 11747
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:33:21
(permalink)
ric I think he is referring to reassembling his old PIC16F1825 code for PIC18F26Q10, so saying those instructions don't exist in PIC18 instruction set.
I realized that after I submitted the post, so I just edited my previous post. ;)
|
ric
Super Member
- Total Posts : 29435
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: online
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:44:07
(permalink)
Note, the PIC18F does not have an equivalent of the BRW instruction, although you can simulate it by writing to PCLATU, PCLATH and PCL. It does have a CALLW instruction, but that might only be available in "extended" mode.
To get a useful answer, always state which PIC you are using!
|
1and0
Access is Denied
- Total Posts : 11747
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:45:12
(permalink)
From you duplicated thread: https://www.microchip.com/forums/m1159335.aspx Do NOT post duplicated thread!!! OsvaldoH Data sheet states: RAM access bit (page 626) a = 0: RAM location in Access RAM (BSR register is ignored) a = 1: RAM bank is specified by BSR register Example 32-1 for A/D in assembler, page 557 , there is not any " ,a" BANKSEL ADCON1 clrf ADCON1 ; I guess it need ,1 for using selected BSR clrf ADCON2 I am asking: What happen when using the option and no place " ,a " value 0 or 1
I suggest you to NOT explicitly write the RAM access bit. MPASM knows best and will automatically insert the correct ACCESS or BANKED bit for you. ;)
|
1and0
Access is Denied
- Total Posts : 11747
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:50:40
(permalink)
ric Note, the PIC18F does not have an equivalent of the ...
I wish Microchip has added some of the "nicer" instructions from the enhanced mid-range instruction set to the newer PIC18 devices, like ASRF, LSLF and LSRF.
|
ric
Super Member
- Total Posts : 29435
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: online
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:54:02
(permalink)
I think one of the XC8 authors commented that they finally got their wish when Microchip added those instructions to the enhanced PIC16F midrange instruction set. Plainly they make life easier for the C compiler. On the other hand, the hardware designers came up with the PIC18F "extended" mode, which the compiler writers turned their noses up at, and never used.
To get a useful answer, always state which PIC you are using!
|
1and0
Access is Denied
- Total Posts : 11747
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: Migrating from PIC16F1825 to PIC18F26Q10
2020/12/02 19:59:00
(permalink)
ric I think one of the XC8 authors commented that they finally got their wish when Microchip added those instructions to the enhanced PIC16F midrange instruction set. Plainly they make life easier for the C compiler.
But not added to the newer PIC18 is ... On the other hand, the hardware designers came up with the PIC18F "extended" mode, which the compiler writers turned their noses up at, and never used.
Yeah, and I do not see why it is still included/changed/added more in the newer PIC18 devices. Go figure!
|