PicPas 0.5.1 is my new compiler for Microchip small devices (16F PIC microcontrollers) :D.Congratulations!
Congratulations!
As I see this is just a beginning... You have a lot of work in front of you.
It is very nice project maybe you want to look at that project too:I have seen something about the JAL project. There were some things I didn't like of JAL. I will check again.
https://github.com/jallib/jallib (https://github.com/jallib/jallib)
Congratulations ;D ;D
I'm working on my very own compiler for the Z80 microprocessor (https://github.com/daar/z80-pascal/tree/wirth_compiler), but I didn't tell anything because it only extracts tokens telling what they are, no code generated yet.
I've briefly look at your code and I must to say that it was ingenious to use SynEdit parser. I'll write it my own.Maybe, you can use the lexer of PicPas, and some of its libraries, like T-Xpres (https://github.com/t-edson/t-Xpres) and SynFacilSyn. The code generator is some very complex module, and T-Xpres helps a lot on this case.
Cool project.
I'm working on my very own compiler for the Z80 microprocessor (https://github.com/daar/z80-pascal/tree/wirth_compiler), but I didn't tell anything because it only extracts tokens telling what they are, no code generated yet.
I've briefly look at your code and I must to say that it was ingenious to use SynEdit parser. I'll write it my own.
Good. Z80 is one of my favourites CPU. Although I have worked a lot with the 6502 CPU, in the Commodore 64. I remember, I wrote a very simple, and low level compiler in BASIC, for this CPU. Some routines of this compiler were "compiled" by the same compiler. %) Sadly, the code has gone with my audio-tapes. :'( Maybe I can rewrite this, in FPC.Thanks for the advices. I'll work on it.
Maybe, you can use the lexer of PicPas, and some of its libraries, like T-Xpres (https://github.com/t-edson/t-Xpres) and SynFacilSyn. The code generator is some very complex module, and T-Xpres helps a lot on this case.
This project, really reuse the code, because the same lexer is used for the editor higjlighter and for the completion tool, too.
Tell me if you need some help on your compiler.
There is experimental FPC branch for z80 here : http://svn.freepascal.org/cgi-bin/viewvc.cgi/branches/z80/?sortby=date&view=log:o
A C64 compiler would be nice too...Plenty of them in the wild.
Hi Edson,
I am experimenting with an uploader/debugger/logic analyzer combination (for lack of a better term) utilizing the FTDI ft2232h chip. The idea is to enable something like PICPas to have a full Lazarus like "RAD" environment functionality. You will be able to compile/upload in one operation and utilize the integrated logic analyzer in-line as the ultimate debugger. It will enable you to "tap" actual pins on the PIC and map them to the logic analyzer, which is fully controlled by the PicPas GUI app as simple project settings, for example. So no more messing with breadboards. It's all safely done in a hands off fashion.
The FT2232h and the larger FT4232h can also be utilized in a loopback fashion as a stand-alone solution. You configure one serial port for uploading to the target PIC chip and utilizing MPSSE (GPIO functionality of the FT2232h via the D2xx.pas) you set up capture pins. This is all that PICPas really needs. Of coarse, this will require coding the logic analyzer in Pascal.
I am currently trying to get this same setup going with Professor Wirth's "PICL", which is his little PIC16C86 compiler. Have you seen it? Less than 800 lines of code including the uploading tools!
https://www.inf.ethz.ch/personal/wirth/PICL/index.html
Why not extending FPC with a PIC backend? FPC has a full featured Object Pascal front end, so no need to bother with this part :D
Uhm ATyny48. It has 2K of flash.
How about working with a 0.5K flash memory device?
Did you see the output of FPC? 42 bytes for a minimal program on avr, a simple blink example is 60 bytes. Extract of inner loop:
pacr:=$4; tccr0:=$05; while true do begin porta:=porta or 4; delay; porta:=porta and not(4); delay; end;
PIC architecture is some problematic, because of the banking for RAM and paging for flash or EEPROM. That's why it is so problematic doing a decent compiler for PIC.And don't forget about the read-modify-write probs :)
It's just you said " ... like the ATtiny28, smaller is basically not possible". So I assume it is not possible to use FPC in a 512 cells memory device.
And don't forget about the read-modify-write probs :)Yes. Fortunately, it's some problem easily avoided, by hardware or software.
Flash is normally not the issue, it is more about the ram :) And this is what I wanted to emphasis: the ATtiny28 has no RAM.I see. But it's relative. AVR has 32 register all mapped in memory, It's almost like the PIC16F83 with 36 bytes of RAM (and only one register).
I use Microchip PICs for a lot of projects, and a Pascal compiler seems interesting and useful.
And found another PIC Pascal project:
http://www.pmpcomp.fr/smf/
http://www.pmpcomp.fr/
I would ask, why Cannot FPC compile to Microchip PIC?
I would ask, why Cannot FPC compile to Microchip PIC?
Because nobody wrote a PIC backend (the part generating code for PIC) for it yet, I decided to go for Z80 first :)
Because nobody wrote a PIC backend (the part generating code for PIC) for it yet, I decided to go for Z80 first :)
I recommend it before explore the mps430 microprocessorIt sounds interesting, but I don't use that MCU. If I would have the necessity, I'm sure, I would write a compiler :).
(https://en.wikipedia.org/wiki/TI_MSP430 (https://en.wikipedia.org/wiki/TI_MSP430)).
There is not yet any Pascal compiler.
PMP was one of the first projects I saw. I must say it is a good compiler, but it depend on Microchip (Assembler, libraries and linker). That's something I didn't liked.Pros and cons.
Is everybody making a Z80 Pascal compiler? This is mine. (https://github.com/daar/z80-pascal) Working in the "wirth compiler" branch now.I would ask, why Cannot FPC compile to Microchip PIC?
Because nobody wrote a PIC backend (the part generating code for PIC) for it yet, I decided to go for Z80 first :)
Is everybody making a Z80 Pascal compiler? This is mine. (https://github.com/daar/z80-pascal) Working in the "wirth compiler" branch now.
I'm not doing a Z80 compiler, but if you take a long time, more and more Z80 compilers will be appearing. :P
Hi Edson,Hi, jc99. I have looked at that, a time ago, but I decided not to use. I don't remember why. %)
you have quiete a program here,
but have you ever tried i18n ?
http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs (http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs)
Hi Edson,
or at least put the Language specific code in separate (language specific folders) from where you include the parts for your prog.
This makes the handling and translating to other language much more easy.
If you like, I just do a German translation.
Exactly that's the problem with that code, (btw. I just checked out trunk, that should be the actual version.) Now you have all languages scattered in one, or lot of separate files,
mnFile.Caption :=Trans('&File' , '&Archivo', '','&Datei');
Thanks.
Exactly that's the problem with that code, (btw. I just checked out trunk, that should be the actual version.) Now you have all languages scattered in one, or lot of separate files,
mnFile.Caption :=Trans('&File' , '&Archivo', '','&Datei');
... and here comes a translation-patch
The control structs are now implemented at the style of Modula-2This is my preference too ::), also found in AvrCo Pascal. Code is easier to look at.
This is my preference too ::), also found in AvrCo Pascal. Code is easier to look at.Yes. Althought AvrCon have the delimiters "ENDWHILE", "ENDCASE", "ENDFOR". It seems me more to Visual Basic syntax, but anyway it's good.
By the way, I was triying to use the PicCo 32, but no success. I compile, but nothing appears, just a beep. It's a very old program, very simple editor and interfaz.Well, PicCo used to work 20 years ago before it was abandoned in favor of AvrCo :-[. AvrCo is much improved (although editor could be better), and the best thing is it's simulator and visual JTAG/PDI debugger. You can set hardware absolute and conditional breakpoints, exec step by step, or browse locals and watches. Sim can even show graphical, line lcd or 7/14seg, and lots of other drivers. It's worth a look.
The three folders samples, temp, and units were created in the application bundle (PicPas-darwin.app → Contents → MacOS). This might still work, but could be probably be improved. Depending on the usage, the should be placed somewhere else. Next came an error message, that the file PicPas_AsmPic.xml could not be loaded. I tried to put the file at a number of places, but none worked. This is probably the related line Source/FormPrincipal.pas: hlAssem.LoadFromFile('PicPas_AsmPic.xml');
I do not really know, what the default path of LoadFromFile is and how it could be set.
...LoadFromFile(DataPath+DirectorySeparator+'Test.dat');
Update for macOS: A s a quick fix specifying absolute paths to files helps.
In addition, there is still an access error. Config is not assigned, when used in the procedure TfraSyntaxTree.ComboBoxEx1Change in file FrameSyntaxTree.pas. I do not really know, how to fix this. I tried to call Config.Inciar, but that failed.
A range check error in FameMessagesWin.pas: timeCnT should be QWord and not Dword.
Changing line 42 to
timeCnt: QWORD;
fixes the range check error.
Next patch ...
CONST
GTSTCK = $005D;
FUNCTION GetStick (CONST aId: BYTE): BYTE;
BEGIN
ASM
LD A, aId;
CALL GTSTCK;
PUSH A
END
END;
; FUNCTION GetStick (CONST aId: BYTE): BYTE;
_fn_$GetStick:
PUSH SP ; Local variable address.
POP IX
; LD A, aId;
LD A, [IX - 3] ; Not sure it will work.
; CALL GTSTCK;
CALL h005D
; PUSH A
PUSH A
; END;
RET
FUNCTION GetStick (aId: __REGISTER_A): __REGISTER_A; BIOSDECL($00D5);
I'm working on my very own compiler for Z80 I'm interested about how do your compiler deal with calls to BIOS that use registers as parameters and result values.
It is too much code IMO. Doing some compiler magic:Code: [Select]FUNCTION GetStick (aId: __REGISTER_A): __REGISTER_A; BIOSDECL($00D5);
I believe there is something like that for Amiga/m68k?It sould. FPC main page says it has m68k as one of the targets. (https://www.freepascal.org/) Unfortunatelly I haven't study FPC sources yet. There are too much files for me. %)
(...) One detail, the identifier "__REGISTER" have some C-ish style, for me.You're right. I'm still defining the internal API. I also like to do it the most Pascalish as possible.
By the way, implementing calls to a BIOS, means to me, that the compiler will be restricted to compile only for that BIOS. I recomend to think the Z80 could work too, in other hardware enviroments, without change, too much, the convention for BIOS calls.The idea is to do something similar to FPC: Using some compiler magic (i.e. -T<target> compiler option) combined with RTL units to implement different targets. I talk about MSX because it is the only one I know but there's people with interest in other platforms (ZX, GameBoy and a custom devices). Anyway I think version 1.0 will use ASM ... END blocks only, as I show in my first example.
It looks great so far. But how long could it be until some of the limitations of PicPas are solved? Arrays, records, float and interruption for example.
Thanks for the comments.I believe there is something like that for Amiga/m68k?It sould. FPC main page says it has m68k as one of the targets. (https://www.freepascal.org/) Unfortunatelly I haven't study FPC sources yet. There are too much files for me. %)
function Open(fname : PChar location 'd1'; accessMode: LongInt location 'd2'): LongInt; SysCall AOS_DOSBase 30;
Sounds good. I can contribute, but not with assembler. Do you need Swedish translation for example?
Thanks. :)Thanks for the comments.I believe there is something like that for Amiga/m68k?It sould. FPC main page says it has m68k as one of the targets. (https://www.freepascal.org/) Unfortunatelly I haven't study FPC sources yet. There are too much files for me. %)
From rtl/amiga/m68k/doslibf.pas:Code: [Select]function Open(fname : PChar location 'd1'; accessMode: LongInt location 'd2'): LongInt; SysCall AOS_DOSBase 30;
d1 and d2 are m68k registers.
I noticed that Github probably has duplicates of files, which only differ in uppercase/lowercase spelling, like globales.pas and Globales.pas or is this on purpose?
Other candidates are formprincipal.* and formpicexplorer.*. Maybe clean up the repository.
Maybe clean up the repository.
Next Update:
BTW:
The Converter to im-/and export [edit] po-files (of cause)[/edit] is on my repo:
https://github.com/joecare99/Public/tree/master/Diverses/FPC -> Prj_PicPas2Po.*
https://github.com/joecare99/Public/tree/master/Diverses/Source/PicPas2Po *
Hi and thank you for this program
.
do you make any help file for this program?
But I'm still not able to compile the sample-programs, like BlinkLed. The compiler gives error-message "BlinkLed[15,5]Error:";"expected."
If I replace the "while true do begin"-loop by "repeat / until false" it works. What do I'm wrong with the original sample-file, why this error-message?
What do you think about a Pascal-Compiler for the STM8-Microcontroller? There are very cheap and powerful boards with the STM8S103F3P6.I'm sure STM8 is a good Microcontroller. It's just I haven't had the necessity of this device. In my country we most use Arduino and PIC. :-[
Such a Pascal-Compiler for this board would be very nice!
Thanks for your great work and for sharing it to us!
German translation:
See pull-request ...
Hello, here my first real PicPas application. It works!
Erni
This program uses 3 bytes of RAM (4,7%) and 44 bytes of FLASH (4,3%)
So I wish a few loadable skins :)Yes. It's projected to include themes. It's not so complicated.
A binary notation for numbers, like 01101001B or %01101001.There is a binary notation: %01101001
A menu to setup the config-word.
Now I have to set the Config-Word with the programmers menu (WinPicPro),
but it should be stored in the HEX-file by the compiler.
The download button to run the external flash-program (or a batch-file).
It can execute the PicKit2-Commandline-Tool for example
and has to give the parameters for file-path, file-name, file-ext
and the processor.
Hi I started to translate the documentation to english ... I started with the Usermanual ...
(also in my repo ... )
Hi I started to translate the documentation to english ... I started with the Usermanual ...
(also in my repo ... )
A "Run External Tool"-menu is a good idea. Please allow more user-entries forOK. I will consider it.
different programs to execute :)
I just finished my second project with PicPas, a speed-controller for my PCB-drill.Do you have some repository for your code? I would like to see it.
It holds the speed stable, also with a PIC 12F629.
Hello Edson,
here the requested documents for the PCB-Drill-Controller uploaded.
Thanks for your interest, please have a look!
Please put it to your PicPas-Project, if you want!OK, It's included in the /sample folder.
Hello,
I noticed there are no Linux precompiled binaries in few last releases. I'd compile them on my own, but unfortunately I'm not clear about how to compile it.
Could you, please, clarify how to compile it?
Change please settings in Main Form (TfrmPrincipal and TConfig dialog):
object inspector\Position = poScreenCenter (or TConfig Position = poMainFormCenter)
I also use AVR, PIC32, ARM and 8051s in my work. You choose the best fitting and most cost effective for your project and not limit yourself based on an particular bias, at the higher level (C/C++) they all work very similar to me.Fair enough, but still I wonder what application you find the PIC saves you time or money?
In this case I have a lot of PIC micros returned by the CM from a previous project so I am using them.If you have a bunch of micros in stock that are just going to lose value then and they could be used for something. Sure. But buying new of them? Unless you sell in the 100k region of boards I really wonder how good of a price you can get on them?
Hi @boz.Thanks
Currently PicPas only support the Mid-Range PIC MCU, like PIC16F887 or PIC16F628. One interesting feature of PicPas is that new devices can be defined usign hardware directives. So theoretically, PicPas can support all devices of the Mid-Range core MCU.
The project PicPas is just beginning, it is in a beta status. I have plans to include the Enhanced Mid-Range and the 18F family of MCU. But it depends on my free time, so probably it won't be soon.
Anyway, this is an open source project so collaborations are welcome.
I see the hardware files in the projects units folder it seems very clean to add another device but it looks like you need to know pic16 assembly which I dont. I am used to C Headers and libraries being available to abstract a lot of the hardware, I'm very familiar with the control registers on the PIC16 and know how to read the datasheet to get things done but I last used assembly on the 8051 in 1987 so I am not sure I am skilled enough to do this, maybe I will have another look when I get some down-time.No need to know ASM, to add a new device. You can define it in the same source code.
I also use AVR, PIC32, ARM and 8051s in my work. You choose the best fitting and most cost effective for your project and not limit yourself based on an particular bias, at the higher level (C/C++) they all work very similar to me.Fair enough, but still I wonder what application you find the PIC saves you time or money?
Please reserve two more languages after German, I started to translate to Ukrainian and Russian.
Here are the files with UA and RU. It seems the translations are okay, but I think I have to improove them later, during my work with the Compiler.
0x005 bcf PORTB, 5
In case if 1 on PORTB.4, output PORTB.5 will make fast pulsation? Is it right?
I think will be right to make any changes in result only AFTER checking of input value.
Tried to simulate in Proteus, and found my laptop have not enough power to simulate this fast pulsation :(
Am I right?
PS We can see it in ASM Debugger if we change the string to PORTB.5 := not PORTB.4;
PORTB.5 blinking because there bcf PORTB, 5 before btfss PORTB, 4
You are right. The code to copy bit PORTB.4 to PORTB.5:
0x005 bcf PORTB, 5
0x006 btfsc PORTB, 4
0x007 bsf PORTB, 5
Could cause a fast pulse on PORTB.5.
It's usually not important, but It could be problematic in some cases.
...
I think It can be defined as an additional optimization parameter that in mode "fast" use this algorithm and in mode "slow" can use a more secure code.
If that code was in a loop, then there would be a constant "pulsing" which would result in a pulse width modulated output and lower average voltage.
Maybe something like this which only adds one instruction:
0x001 btfsc PORTB, 4
0x002 bsf PORTB, 5
0x003 btfss PORTB, 4
0x004 bcf PORTB, 5
I think this should be the normal operation. And, an optimization switch could be to enable your original method of speed while sacrificing output consistency.
PicPas has been updated to the version 0.6.0 :D. All bit operation implemented, more optimization code included, tree syntax improved, parameters of procedures implemented, interfaz modified, and many other features more.
I know it's not a good question, but I often wonder why people use PIC controllers. What keeps you using them?
They aren't really cheap, and the architecture is not suited for compilers or humans.
Some say they are great for noisy environments, but anything running that slow will work in a noisy environment.
Creating a compiler for it is a great feat for sure. So kudos for the project :)
What is the graphical emulator you are using in the background? Is that a third party tool?Thanks.
The debugger is fantastic. What more could you want?
Bravo!
Hi Edson,
Here is a translation to English of the excellent UART example. Hope it helps.
Hi Edson,
Do you plan on implementing the set type or are sets to high level for the PIC?
PicPas, my cross-platform Pascal compiler for Microchip PIC, is growing. Now in the version 0.8.3, it improves the disassembling and includes some adiitonal optimizations in RAM use. https://github.com/t-edson/PicPas
The README.md describes a file called PicPas-linux, but I could not find that in your github repository.
Compiling from source gives this error:
FormPrincipal.pas(11,3) Fatal: Cannot find SynFacilHighlighter used by FormPrincipal of the Project Inspector.
Are there dependencies for source compilation?
Yes. To compile you need to download all the Third Party libraries:
..\..\_Librerias\SynFacilUtils-1.21;
..\..\_Librerias\MisUtils 0.5;
..\..\_Librerias\MiConfig 0.4b;
..\..\_Librerias\PicUtils-1.2;
..\..\_Librerias\Xpres-1.3.2;
..\..\_Librerias\UtilsGrilla 0.8;
..\..\_Librerias\ogEditGraf 1.6b
All are mine so you can find them in my GitHub.
Can you put that text in the READM.md under requirements
..\..\_Librerias\Xpres-1.3.2;
should be
..\..\_Librerias\t-Xpres-1.3.2;
Problem: MisUtils.pas(435,10) Error: Identifier not found "FileExistsUTF8"
Cause: The function FileExistsUTF8 in the fileUtil it is depreciated.
Solution: Add LazFileUtils unit to uses in MisUtils.pas
It's at the bottom of the text. Maybe it needs to be more specific. :-\I should read more, thanks :-[
Problem: MisUtils.pas(435,10) Error: Identifier not found "FileExistsUTF8"
Cause: The function FileExistsUTF8 in the fileUtil it is depreciated.
Solution: Add LazFileUtils unit to uses in MisUtils.pas
Maybe it's because of the version. PicPas 0.8.3 use "MisUtils 0.5". The default version in GitHub is 0.6. You need to select the previous version.
Tell me if you have problems. Maybe I need to update PicPas to "MisUtils 0.6".
Hi,
PisPac is a very interesting and useful tool.
I tried some examples.
Unfortunately, nested cycles do not work.
hi ! is it mean that we can compile a program for famous Arduino or Teensy?
Or AtTiny?
hi ! is it mean that we can compile a program for famous Arduino or Teensy?
Or AtTiny?
The fpc compiler can already compile to AVR, see wiki (http://wiki.freepascal.org/AVR_Programming).
PicPas is a different pascal compiler that targets a different controller family. Note that fpc doesn't support the PIC controller family.
[…] (I have no idea of what is "PIC")in general programmable integrated circuit; but here the short/colloquial name for PIC μController (https://en.wikipedia.org/wiki/PIC_microcontroller)
Hello, when will be PIC18/24 support? Is there the plans about support this pic families? ::)
Thanks Edson, for your work ! I love PIC !!You're welcome.
Does PicPas compiler support the ENHANCED MID-RANGE CPU like 16F1825 ?No yet. It's the next step. PicPas have now, the ability to support multiple PIC compilers in the same IDE, so it's not dificult to include a compiler for this family. The hard work would be to update some routines in the Code Generator and in the Real-time simulator.
If yes, I would like to help you and write the description file for this PIC (PIC16F1825.pas)You can write the description file now and so, you are helping to have support for the Enhanced Mid-range family. It would be better if you write hardware description for: PIC16F1454 PIC16F1455 PIC16F1459 PIC16F1503 PIC16F1507 PIC16F1508 PIC16F1509 PIC16F1512 PIC16F1513 PIC16F1516 PIC16F1517 PIC16F1518 PIC16F1519 PIC16F1526 PIC16F1527 PIC16F15313 PIC16F15323 PIC16F15324 PIC16F15325 PIC16F15344 PIC16F15345 PIC16F15354 PIC16F15355 PIC16F15356 PIC16F15375 PIC16F15376 PIC16F15385 PIC16F15386 PIC16F1574 PIC16F1575 PIC16F1578 PIC16F1579 PIC16F1613 PIC16F1614 and some others.
How do you set the config bit for the PIC ? I can't found any example in the sample folder
Ok Edson. I'm too busy at this time, so I go slowly on the description files asked...
In fact, I'm trying to develop a program to automate the task as much as possible from existing include files. :-X
I noticed that in the file PIC16F877.pas (my reference to understand how to declare a pic) there is the line:Well. I haven't written this files. They are part of some collaboration. But I guess the idea of setting 0x000 as "Unimplemented" is because INDF is not implemented as a register.After some search in the datasheet, I found 'reading the INDF register itself, indirectly
{$SET_UNIMP_BITS '000:00'} // INDF
(FSR = '0') will read 00h'. That's why you add this line?
second question: in PIC16F877.pas again, section Configuration Bits:Strange. They seem to be clearly an error. I will ask to the person who made this file.There are masks on 5 digits but the configuration register is on 14 bits ... is this an error?
// WDTE : Watchdog Timer Enable bit {$define _WDTE_ON = $13BFF} // WDT enabled {$define _WDTE_OFF = $3BFF} // WDT disabled // FOSC : Oscillator Selection bits {$define _FOSC_EXTRC = $63BFF} // RC oscillator {$define _FOSC_HS = $43BFF} // HS oscillator {$define _FOSC_XT = $23BFF} // XT oscillator {$define _FOSC_LP = $3BFF} // LP oscillator
I noticed another problem: I'm working on PIC16F1454.pas as you asked.
This pic has two configuration word located at adresses $8007 and $8008.
The PIC16F877 has only one configuration word located at $2007.
How do you specify the adress of the configuration word ? I don't see it in existing description files.
Excelent!I'm happy to contribute !
This is the first hardware description of a Mid-range Enhanced Core CPU PIC.
But I don't see the mapped section for the 16 lower bytes GPR. They must be mapped too, or the compiler will calculate bad the free RAM and would use this wromg this range of RAM.that's what I thought ... Added.
A minor detail: Line 777 is: // -- Bits Configuration Word 1 --Corrected
Must be: // -- Bits Configuration Word 2 --
The best test of this unit will be when compiling programs or simulating the execution. Anyway the compiler is still in progress.Good, Let's go to the other Enhanced Mid-range !
Hi, ok I stop the work on the units. Cuistax did a lot of work !
cool! BUTI think this is not the subject of this topic... Here we discuss about Edson compiler for Microchip PIC microcontrollers !
due to the lack of file formats support, I will still use
https://www.freecadweb.org (https://www.freecadweb.org)
because it is simply awesome
https://www.freecadweb.org/wiki/Import_Export (https://www.freecadweb.org/wiki/Import_Export) << files formats
EDIT: are SFR mapped areas (thus declared with {$ SET_MAPPED_RAM 'xxx-xxx: bnk0'}) also to be declared with the {$ SET_STATE_RAM 'xxx-xxx: SFR'} directive?
EDIT: I think it will be useful if the compiler notify an error if an ram adress is defined as mapped and not defined in STATE section.Excellent suggestion. I will check it for the next version and I will see too, if include some new directives to set state or map RAM for all banks. This will reduce the size of units.
That's great !
I tryed to add a led on project 'samples\BlinkLed.pas': the led and its resistor appears on the screen but when I right click on the pin 7 of the PIC, it appears an exception SIGSEV in file FramePicDiagram.pas line 1051.
How do you implement the size of the EEPROM ? There isn't a directive for this.
It's interesting project :)
Is future version support word by word multiply calcuation?
It's interesting project :)
Is future version support word by word multiply calcuation?
Hi.
Some aritmethic operation are not implemented. I'm doing a redesign of the compiler.
You can implement a function to multiply Word * Word:
uses PIC16F84A; procedure Mult(SYS_MATH_NUM_A, SYS_MATH_NUM_B: word): word; var SYSBYTETEMP_01: byte; begin SetBank(0); ASM ;[W_H] = SYS_MATH_NUM_A * SYS_MATH_NUM_B ;SYS_MATH_NUM_X = 0 clrf SYSBYTETEMP_01 clrf _H MUL16LOOP: ;Si SYS_MATH_NUM_B.0 = 1 entonces [W_H] += SYS_MATH_NUM_A btfss SYS_MATH_NUM_B.Low,0 goto ENDIF1 movf SYS_MATH_NUM_A.Low,W addwf SYSBYTETEMP_01,F movf SYS_MATH_NUM_A.High,W btfsc STATUS_C addlw 1 addwf _H,F ENDIF1: ;STATUS.C := 0 bcf STATUS_C ;rotar SYS_MATH_NUM_B derecha rrf SYS_MATH_NUM_B.High,F rrf SYS_MATH_NUM_B.Low,F ;STATUS.C := 0 bcf STATUS_C ;rotar SYS_MATH_NUM_A izquierda rlf SYS_MATH_NUM_A.Low,F rlf SYS_MATH_NUM_A.High,F ;Si SYS_MATH_NUM_B > 0 entonces goto MUL16LOOP movf SYS_MATH_NUM_B.Low,w iorwf SYS_MATH_NUM_B.High,w btfss STATUS_Z goto MUL16LOOP ; SYS_MATH_NUM_B > 0 movf SYSBYTETEMP_01,w END end; var a, b, c: word; begin a := 100; b := 200; c := mult(a, b); end.
This routine uses only 23 cells of memory.
But I guess result is dword. Sometimes it is needed for 10 bit adc multiplication for power checking. It may be useful.
But I guess result is dword. Sometimes it is needed for 10 bit adc multiplication for power checking. It may be useful.
I don't know if it's really needed so much precision when working with ADC but you can get 32 bits math routines here: https://github.com/AguHDz/PicPas-Librerias_y_Programas/blob/master/Math_Code/Math_32bits.pas
Hi,Hi.
Just new in PICPAS, trying to learn it.
I built a small board with a PIC16F84A to do the initial tests.
My first problem is with the quartz crystal, for those chips that do not have UART on it, I run them with a 3.2768 Mhz xtal to derive the frequency for the soft uart. I've seen in the docs the $FREQUENCY directive admits MHZ and KHZ.
Using decimals is not allowed (I get an error) although I was thinking the compiler was written in Lazarus and it does support them. Anyway I tried 3276800 HZ, but HZ are unsupported also. So (just to run the "hello LED" initial program) I forgot about the last digit and put 3276 KHZ. This time the figure was accepted but I got another error telling that this frequency is not allowed because that clock frequency is not supported for delay_ms().
So I'm running it with a $FREQUENCY 4 MHZ and tolerating the clock deviation for the initial tests.
Should I conclude the only valid allowed frequencies are only integer MHZ/KHZ with all trailing zeroes?.
Thanks in advance.
Jes.
Hello, great work :),
Is {$CONFIG2 ...} implemented in Enhanced Mid-range Compiler in version 0.8.8 ?
program FT290_display_2;
uses PIC16F1939;
{$FREQUENCY 8MHZ}
{$CONFIG _FOSC_INTOSC, _WDTE_OFF, _PWRTE_OFF, _MCLRE_OFF, _CP_OFF, _CPD_OFF, _BOREN_ON, _CLKOUTEN_OFF, _IESO_OFF, _FCMEN_ON}
{$CONFIG2 _WRT_OFF, _VCAPEN_OFF, _PLLEN_ON, _STVREN_ON, _BORV_LO, _LVP_ON}
...
FT290-display-2[29,3] Error: Unknown directive: CONFIG2
PicPas is now available as Snap package https://snapcraft.io/picpas
Related necessary changes to the project can be seen here: https://github.com/chronoscz/PicPas/commit/a816e0467a9dbda9d3d4c70be90a133577c694eb
Instructions how to create snap are available here https://wiki.freepascal.org/Create_snap_package
Some of my observations:
* The application doesn't remember windows size and position.
* Scaling and High DPI support is not enabled. So windows and text looks wrong under high DPI.
* File open and save dialog won't use path to current opened file or last used path.
* Application config file PicPas-linux.xml should be better placed into user config directory. Use function GetAppConfigDir(False) to get that directory. Also don't put your local recent files into that file and into git. It should be initialized as clean.
* Wrong relative paths to libraries in project Debug build mode. But its good that they are present in repository so one doesn't need to download them manually.
* Temp directory should be located under linux in /tmp directory or something like /tmp/PicPas or /tmp/PicPas-username. Or it can be also located in user config dir as temp.
* Use .gitignore file to ignore dynamically created directories and files like project.lrs, project.res and project/lib.