Recent

Author Topic: PicPas, Pascal compiler for Microchip PIC  (Read 115070 times)

Lulu

  • Full Member
  • ***
  • Posts: 226
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #195 on: June 15, 2018, 12:57:48 pm »
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.
« Last Edit: June 15, 2018, 02:31:12 pm by Lulu »
wishing you a nice life

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #196 on: June 15, 2018, 04:43:09 pm »
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.

Have you used the last version of PicPas? This happened in 0.8.7 when testing. If teh error persist, please send a screenshot.

How do you implement the size of the EEPROM ? There isn't a directive for this.

EEPROM is considered a peripheral, like Timers and Watchdog, and Picpas does not have support to define (and simulate) pheripherals, by now.

When implemented, we are going to need new directives not only for EEPROM.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

aljunaid

  • Newbie
  • Posts: 1
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #197 on: January 10, 2019, 10:49:34 am »
Just posting how to compile PicPas for windows-32bit / Lazarus 1.8.4;
sourcd-libraries\ are;
MiConfig-0.4.zip
MisUtils-0.6.zip
ogEditGraf-2.4.zip           (OLD VERSION)
PicUtils-1.6.zip
SynFacilUtils-1.21.zip
t-Xpres-1.3.2.zip
UtilsGrilla-0.8.zip

The patchfile  patch-language_tra_FrameArcExplor.pas  is from ;
https://svnweb.freebsd.org/ports/head/editors/picpas/files/
(I think the author uses a Spanish-localized version Lazarus
library names in language_tra_FrameArcExplor.pas  . This
needs fixing to at least select english function names on english systems.
I also noted that selecting Tools.Settings.IncludeDetailedComments = ticked   causes an exception when compling (on baseline project).
Would be nice if the PicPas IDE would remember type of Compiler
selected for current project instead of defaulting to Midrange all the time.


runme.bat:
-------------------------------------------------

goto libs

- File.Open = PicPas-0.8.8\Source\PicPas.lpr

-Project.OptionsForProject.CompilerOptions ;
   .Debugging.StripSymbols= ticked

-Project.OptionsForProject.CompilerOptions.Paths ;
   -shows that this project is looking for libraries in
    Source\..\..\_Librerias\XXXXXX\
:libs
   cd PicPas-0.8.8\Source
   md ..\..\_Librerias
   cd ..\..\_Librerias
   unzip source-libraries\*.zip
      REM h:\dl\electron\pic\compiler\PicPas\source-libraries\
   ren t-Xpres-1.3.2 Xpres-1.3.2
   cd ..\PicPas-0.8.8\language
   G:\MinGW\bin\patch.exe --strip=1 < compiling\patch-language_tra_FrameArcExplor.pas
      REM h:\dl\electron\pic\compiler\PicPas\compiling\
   cd ..
   copy PicPas-win64.xml PicPas-win32.xml
   goto end

-Run.Compile



:end



Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #198 on: January 10, 2019, 07:35:06 pm »
Thanks for the information @aljunaid

There're some issues easy to solve.

I'll be revising PicPas later. Currently I'm experimenting with new compilers to translate that experience to PicPas and make it a better compiler.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

parcel

  • Full Member
  • ***
  • Posts: 142
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #199 on: March 12, 2019, 02:11:23 pm »
It's interesting project :)

Is future version support word by word multiply calcuation?



Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #200 on: March 12, 2019, 07:29:46 pm »
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:

Code: Pascal  [Select][+][-]
  1. uses PIC16F84A;
  2.  
  3. procedure Mult(SYS_MATH_NUM_A, SYS_MATH_NUM_B: word): word;
  4. var
  5.   SYSBYTETEMP_01: byte;
  6. begin
  7.   SetBank(0);
  8.   ASM
  9.   ;[W_H] = SYS_MATH_NUM_A * SYS_MATH_NUM_B
  10.  
  11.   ;SYS_MATH_NUM_X = 0
  12.           clrf    SYSBYTETEMP_01
  13.           clrf    _H
  14.   MUL16LOOP:
  15.   ;Si SYS_MATH_NUM_B.0 = 1 entonces [W_H] += SYS_MATH_NUM_A
  16.           btfss   SYS_MATH_NUM_B.Low,0
  17.           goto    ENDIF1
  18.           movf    SYS_MATH_NUM_A.Low,W
  19.           addwf   SYSBYTETEMP_01,F
  20.           movf    SYS_MATH_NUM_A.High,W
  21.           btfsc   STATUS_C
  22.           addlw   1
  23.           addwf   _H,F
  24.   ENDIF1:
  25.   ;STATUS.C := 0
  26.           bcf     STATUS_C
  27.   ;rotar SYS_MATH_NUM_B derecha
  28.           rrf       SYS_MATH_NUM_B.High,F
  29.           rrf       SYS_MATH_NUM_B.Low,F
  30.   ;STATUS.C := 0
  31.           bcf       STATUS_C
  32.   ;rotar SYS_MATH_NUM_A izquierda
  33.           rlf       SYS_MATH_NUM_A.Low,F
  34.           rlf       SYS_MATH_NUM_A.High,F
  35.  
  36.   ;Si SYS_MATH_NUM_B > 0 entonces goto MUL16LOOP
  37.     movf    SYS_MATH_NUM_B.Low,w
  38.     iorwf   SYS_MATH_NUM_B.High,w
  39.     btfss   STATUS_Z
  40.     goto    MUL16LOOP     ; SYS_MATH_NUM_B > 0
  41.    
  42.     movf    SYSBYTETEMP_01,w
  43.   END
  44. end;
  45.  
  46. var
  47.   a, b, c: word;
  48. begin
  49.   a := 100;
  50.   b := 200;
  51.   c := mult(a, b);
  52. end.

This routine uses only 23 cells of memory.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

parcel

  • Full Member
  • ***
  • Posts: 142
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #201 on: March 13, 2019, 12:13:33 pm »
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:

Code: Pascal  [Select][+][-]
  1. uses PIC16F84A;
  2.  
  3. procedure Mult(SYS_MATH_NUM_A, SYS_MATH_NUM_B: word): word;
  4. var
  5.   SYSBYTETEMP_01: byte;
  6. begin
  7.   SetBank(0);
  8.   ASM
  9.   ;[W_H] = SYS_MATH_NUM_A * SYS_MATH_NUM_B
  10.  
  11.   ;SYS_MATH_NUM_X = 0
  12.           clrf    SYSBYTETEMP_01
  13.           clrf    _H
  14.   MUL16LOOP:
  15.   ;Si SYS_MATH_NUM_B.0 = 1 entonces [W_H] += SYS_MATH_NUM_A
  16.           btfss   SYS_MATH_NUM_B.Low,0
  17.           goto    ENDIF1
  18.           movf    SYS_MATH_NUM_A.Low,W
  19.           addwf   SYSBYTETEMP_01,F
  20.           movf    SYS_MATH_NUM_A.High,W
  21.           btfsc   STATUS_C
  22.           addlw   1
  23.           addwf   _H,F
  24.   ENDIF1:
  25.   ;STATUS.C := 0
  26.           bcf     STATUS_C
  27.   ;rotar SYS_MATH_NUM_B derecha
  28.           rrf       SYS_MATH_NUM_B.High,F
  29.           rrf       SYS_MATH_NUM_B.Low,F
  30.   ;STATUS.C := 0
  31.           bcf       STATUS_C
  32.   ;rotar SYS_MATH_NUM_A izquierda
  33.           rlf       SYS_MATH_NUM_A.Low,F
  34.           rlf       SYS_MATH_NUM_A.High,F
  35.  
  36.   ;Si SYS_MATH_NUM_B > 0 entonces goto MUL16LOOP
  37.     movf    SYS_MATH_NUM_B.Low,w
  38.     iorwf   SYS_MATH_NUM_B.High,w
  39.     btfss   STATUS_Z
  40.     goto    MUL16LOOP     ; SYS_MATH_NUM_B > 0
  41.    
  42.     movf    SYSBYTETEMP_01,w
  43.   END
  44. end;
  45.  
  46. var
  47.   a, b, c: word;
  48. begin
  49.   a := 100;
  50.   b := 200;
  51.   c := mult(a, b);
  52. end.

This routine uses only 23 cells of memory.

Thank you.

But I guess result is dword. Sometimes it is needed for 10 bit adc multiplication for power checking. It may be useful.


Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #202 on: March 14, 2019, 03:59:21 am »
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
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

parcel

  • Full Member
  • ***
  • Posts: 142
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #203 on: March 14, 2019, 08:37:19 am »
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

Thank you  :)

I have small project for solar panel MPPT. 
It uses 12F675 and it need word multiplication.
I already finished by other PIC compiler and I try to porting to PICPAS.

 https://github.com/rasberryrabbit/PIC12F675MPPT/blob/master/12f675%20MPPT.mpas
« Last Edit: March 14, 2019, 12:52:59 pm by parcel »

jesito

  • Newbie
  • Posts: 1
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #204 on: January 13, 2020, 05:59:25 pm »
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.

lazdeveloper

  • Jr. Member
  • **
  • Posts: 61
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #205 on: January 14, 2020, 12:52:39 am »
Great project. Please note that such projects require a long
Term support. So keep it alive by keeping behind it.

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #206 on: January 14, 2020, 04:43:58 am »
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.
Hi.
PicPas only works with some specific  frequencies because it needs to implement delay routines. These frequencies are: 1MHz, 2Mhz, 4Mhz, 8MHz, 10MHz, 12MHz, 16MHz and 20MHz.
It's possible the compiler can work with any clock frequency. This information is only needed for delays routines, and for calculations in real time simulation.
You could use 4MHz or something other frequency and works OK with the compiler. The limitation would be, if you use delay_ms()  function it won't be exact. You would need to implement your own delay code if you need it.
It would be possible to implement a more generic delay algorithm for the compiler and include it. By now I'm redesigning some parts of the code generator. I prefer to do changes after the new design.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #207 on: September 08, 2020, 09:53:07 pm »
Hi,
I was a little occupied for some time , but now I had the oportunity to update the german translation for PicPas, I just opend a pull request in github ...
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #208 on: September 09, 2020, 03:22:20 am »
OK. I will be checking. Thank you.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #209 on: September 11, 2020, 01:02:59 pm »
I'd suggest to add another column for chinese, then I could append the .Po translaton from 郑建平@夏宗萍 aka  robsean <<robsean@126.com>>, and maybe some more optional ones for future additions.BTW could someone have a look into the .po because personally I don't speak chinese.
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

 

TinyPortal © 2005-2018