Recent

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

Lulu

  • Full Member
  • ***
  • Posts: 111
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 »
fpc 3.0.4 Lazarus 1.8.0  -  AMD A8-6600K  -  Windows 10  64bits
bad english... sorry :)

Edson

  • Hero Member
  • *****
  • Posts: 1021
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 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

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: 1021
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 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

parcel

  • Full Member
  • ***
  • Posts: 135
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: 1021
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 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

parcel

  • Full Member
  • ***
  • Posts: 135
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: 1021
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 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

parcel

  • Full Member
  • ***
  • Posts: 135
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 »