-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for new PICs #39
Comments
Hi. I don't have a special list. You can add what you consider important. One detail, Some definitions need to be completed. |
PICS 16F1825 and 16F1829 are part of the new Enhanced Mid-Range Core 16F. They have a very different architecture from the classic 16F PICs. PicPas has not support to this models by the moment. Implementation require a considerable work. |
Hello, |
Regarding the support of additional PICs, I had a look at file Pic16Devices.pas. I am concerned that the current way of defining models (through source code) will not scale very well with a growing number of supported models. It's ok for a small number of models, as it is the case now, but it will be hard to maintain with ten times more models. I think those definitions could better be off-loaded to external files (like .xml or .csv files) and loaded at runtime. It least it would make the process of adding PIC models easier. What do you think ? I will think about it and probably come up with a concrete proposition. |
There are a lot of differences on working with the Enhanced architecture. First of all PicPas is not only a compiler/IDE, it's a simulator too, and it's all integrated. |
Defining new devices can be done in compilation time, including the definition in the source file. Just check the README.md file, in the description of the directives $SET_STATE_RAM, $SET_MAPPED_RAM, $CLEAR_STATE_RAM:
A real device would be more complex but the idea is the same. |
Hello, I put the PIC16FXYZ.pas in the "units" folder. What else should I do ? Please find files hereafter: |
Nevermind I got it working. Thanks anyway! I join the fixed files in attachment, just for the record. |
Good. That's is exactly how new devices must be defined in compilation time. Using directives and putting all of them in a separated unit. In this case it's not necessary to use {$PROCESSOR ...} In fact {$PROCESSOR ...} is just an abreviated form for all directives defining a device, but {$PROCESSOR} it's faster because use internal declarations (defined in Pic16Devices.pas). |
Hey, I have added units to cover the whole PIC mid-range models. Pull request: #40 |
Good. I will commit and review. Now all Mid-range models will be covered by PicPas. Thanks. |
Oops it looks all new unit files were wrongly added to the root folder instead of the "units" folder. |
OK. I'm going to create a new branch to define the folder "/devices" in order to avoid compatibility problems. I will be the 0.8.5 version. I' going to include new changes too, about graphical interfaz of the debugger. |
Absolutely.
I understand the challenge. I can quickly provide the device/unit files for the baseline models, if it helps ;) |
Definitely. It's just not implemented by now.
Good excercise.
OK. I have opened the branch 1.4 for PicUtils: https://github.com/t-edson/PicUtils and created two new units: PicBaseDevices.pas and PicBaseUtils.pas. |
Very good! On my side I have added device units for PIC baseline models (all models existing at this time): #44 The list of added models is: PIC10: PIC12: PIC16: |
PicBaseUtils is definitely a better name than Pic10Utils since, as you can see in the post above, the baseline range contains PIC10, PIC12 and even some PIC16 models. And, since you are asking my opinion ;), I take this opportunity to raise another point : I have been trying to read the source code (because I would like to be able to also help in that department) but unfortunately it's hard for me to make sense of it, as it requires spanish language skills that I don't have. It's not impossible, but it makes it harder to understand. I fully understand the reason, but if it does not make a big difference for you, it will be much easier for others to contribute if english was predominantly used instead. Anyway, that's my 2 cents. |
Good. But It won't work.
Just will set the 14 bits PIC core. And all the other functions like compiling, assembling, linking and simulating, will be applied to the same 14 bits Mid-range core. Even the *.hex will be for 14 bits. We need to have another PIC core in the compiler (some like the TPIC16 class). That's why we need to create the units PicBaseDevices.pas and PicBaseUtils.pas, including new memory models, new instructions, new SFR, new memory manager rouitines, new *.HEX file, ... Then we need to see, How to include this new PIC object in the compiler? How to swicht the compiler, linker and code generator in the compiler when a Baseline device is used. All of this after create a new compiler, linker and code generator for the Baseline. OK I will modify the PicBaseDevices.pas and PicBaseUtils.pas files. Can you tell me: |
Yes I know. I was just doing my part ;)
It ranges from 1 page / 1 bank (PIC10F200) to 4 pages / 8 banks (PIC16F570). Here's an exhaustive list:
Also, please note that pages are 512-words long and not 2048-words long as in the Mid-Range. |
I made this small document for myself some time ago, maybe you will find it useful. |
OK. I will be translating in successive versions. It will take some time. Ayway If you have some question There is also a Technicall documentation, but it's in spanish too. I can share it if you need. |
As for the switch of compiler, maybe a directive in the units will do, like:
...with 'Mid-Range' being the default if none is specified, for backward compatibility. If it's specified in every device unit file, the user wouldn't even have to worry about it. |
I was thinking in something like that. A directive before all PIC definitions directives. That would change switch the current PIC device (compiler, linker, assembling, code generator, simulator). Other option I considered was using differentes object PIC: {$SET PICBASE_MODEL = 'PIC10F200'} This have some advantages, like having static fields. Why PIC_ARCH? I prefer something like PIC_FAMILY. "Enhanced" could be ambiguous, because I read there is a Baseline Enhaced. |
I am changing the "PicBaseUtils" and I have defined most off the stuff for the 12 bits Core. It will be ready soon. But there is a lot of work later when implementing a code generator for 12 bits, that can be copied in most from the 14 bits code generator. |
I guess I could try. What functions need to be updated exactly ? |
First I'm going to create the units then you would see what is needed. |
I don't really finish on understand the TRIS instruction in the Baseline. The Opcode is: |
According to my tests with mpasmx, the TRIS instruction accepts operands between 5 and 9. And according to the disassembly below, it seems the instruction encoding is:
So, it seems there's actually two encodings for this instruction: 0000 0000 01xx and 0000 0000 10xx. This has been tested on the PIC10F200 and the PIC16F570 (the two extremes of the baseline range) and the result is identical. |
OK. I's done that way too in https://github.com/t-edson/PicUtils. It's strange some datasheet are wrong or have incomplete information. It'a a good progress :) . |
The next step is to make PicUtils works in PicPas. The first unit to modify is "GenCodBas_PICBase.pas". It includes some basic routines of the Code Generator. You can download de Source of PicPas (and update PicUtils too) and try to compile inlcudind the Unit GenCodBas_PICBase in the FormPrincipal.pas unit (Uncomment line 12) and you will see the errors in "GenCodBas_PICBase.pas", mainly because of the lack of the instructions ADDLW or SUBLW. It's needed to adapt the code using other instructions. |
I have updated de unit GenCodBas_PICBase.pas. Next Step is create the unit GenCod_PICBase and here is where all the operations of the Code Generator are implemented. This will take some time. |
Ok, even though I guess you already know that "PIC10" refers to 6-pin devices, and not the baseline range. But I guess it does not matter much what the class is named in the source code. Code readability is a good point. What matters most, on the other hand, is the PIC architecture directive that users specify in their source code, which should be as unambiguous as possible. |
Yes. I know the name PIC10 is not exactly, as PIC16 is not too. They are just nomenclatures used in the source code to improve the readability. It's because a number helps to associate a PIC family when using a composite name. Later we can use PIC17 and PIC18 for the others families. I don't know the criterias Microchip use to asign name to his PIC families but I guess it could be done better. |
Unit GenCod_PIC10 is ready!!! with some operations not implemented and not tested yet, but we can say the Baseline have a code generator now. and define the commom RAM, using: A revisions of all units may be needed. I was thinking on creating new folders, something like: /devices10, /device16, /device18 ... It's some confusing to have diferent families of units in one folder. |
Excellent. I can update the device models to include the missing directives. Regarding devices folders. What grouping do you suggest ? If that can help, I made a table below to summarize what models are present in what range line. The way I see it, it can be grouped, either: So, it's not about choosing the best way, it's more about choosing the less wrong ;)
|
I prefer to group by Baseline/Mid-Range/Enhanced Mid-Range
So we can have different folders: /devices10, /devices16, /devices17, /devices18, that will be useful and secure considering that we have different compilers for different families. So we can indicate to a specific compiler searchs his units in a specific path and avoid try to compile a different family (This happened in some test I made, and the compiler crashsed). By the way, When updating fodler /devices I remember I found a Mid-Range PIC model that have not a unit created. I don't remember the code. |
Finally I got a functional class TCompiler_PIC10, that is the compiler object for the Baseline family. :) |
Hi, I just saw you had to fix several unit files. There was indeed an issue in the baseline headers I created, the mirrored registers were not correctly set. For instance, you changed the file for to PIC16F57 as follows in commit 2f1b1259999dc93a2fa26b30048377fd3930f540
It's indeed more accurate, but still not completely right. For instance, registers 0x20 to 0x27 are defined as GPR registers but in reality they are mirrors of SFR registers 0x00 to 0x07 (as set by the SET_MAPPED_RAM directive). Taking that point into account, I think the most accurate definition would be:
Would you agree with that ? |
OK. I agree. Please update the units. And if it's needed include the new directive $SET_UNIMP_BITS1 to define unimplemented bits read always as "1". |
Hi. Someone has noted the configuration bits defined in unit PIC16F877.pas seems to be wrong:
Because the length of the word is only 14 bits. |
Yeah, good catch ! |
Good. Some user is collaborating with the units for the Enhanced Mid-range. You can check it in the Lazarus forum. |
Well, you should have asked me, I already made them ;) Let me know if you want them (I have 119 files ready). |
Both issues are fixed. Check out #49 |
Some observations: |
I didn't know you have made it. Please upload them to /devices17. I have created a new compiler (PIC17) to support this new family. It's just a test no yet functional but can be used to test the Devices units. |
Yes, another good catch ! These are fixed in #50 |
Enjoy : #51 ! |
Just a quick note about the /devices16 folder, I think the two following files should be deleted:
I can do it if you want. Also, you were previously talking about missing models, do you remember what those were ? |
Yes. Do it please. I don't remember what were the missing models but I will tell you if I find them again. |
Hello again,
As I said earlier, I would be happy to add support for other PIC models.
I noticed that many newer PIC actually have 2 config words, CONFIG1 and CONFIG2, located at address 0x8007 and 0x8008 (see for instance the datasheet of PICS 16F1825/16F1829).
I believe it is not currently supported.
How easy would it be to make PicPas handle 2 config words ?
In the mean time, I could add support for the PICs that still use a single config word.
Do you have a list of favorite models that you would like to see supported in priority ?
The text was updated successfully, but these errors were encountered: