Recent

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

boz

  • New Member
  • *
  • Posts: 10
    • Roving Dynamics Ltd
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #120 on: November 06, 2017, 07:47:25 pm »
Looks very nice. great Work.

I migrated from Mikropascal to MPLABX/XC8 about 6 years ago and these days I mostly use the newer PIC32 and 18F26K42 in my embedded projects.

I do have a current open source project that uses a larger 16F18857 device (http://rodyne.com/?p=844) it would be nice to try making a more complicated project for this (I hate string support in C!) are there any plans to support these newer bigger chips or (as there are so many) are there plans to allow us to configure our own chips?

Boz
Roving Dynamics Ltd
www.rodyne.com


Boz
Roving Dynamics Ltd
www.rodyne.com

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #121 on: November 06, 2017, 10:24:52 pm »
Hi @boz.

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.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #122 on: November 06, 2017, 10:39:49 pm »
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  :)

boz

  • New Member
  • *
  • Posts: 10
    • Roving Dynamics Ltd
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #123 on: November 06, 2017, 11:06:50 pm »
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. In this case I have a lot of PIC micros returned by the CM from a previous project so I am using them.

I also drink Pepsi sometimes instead of coke and sometimes drive Japanese cars over European ones, I'm probably too old to worry about being trendy or I probably wouldn't be using Pascal :)
Boz
Roving Dynamics Ltd
www.rodyne.com

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #124 on: November 06, 2017, 11:16:00 pm »
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?

Quote
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?

boz

  • New Member
  • *
  • Posts: 10
    • Roving Dynamics Ltd
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #125 on: November 07, 2017, 01:22:38 am »
Hi @boz.

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.
Thanks

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.

Keep up the great work.
Boz
Roving Dynamics Ltd
www.rodyne.com

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #126 on: November 07, 2017, 02:57:12 am »
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.

The following example, taking from the User Manual, defines a new PIC16F84 devices, with more FLASH memory:

Code: Pascal  [Select][+][-]
  1. program MiPICprogram;
  2. //Defines basic hardware
  3. {$SET PIC_MODEL='MIPIC'}
  4. {$SET PIC_MAXFREQ = 1000000}
  5. {$SET PIC_NPINS = 18}
  6. {$SET PIC_NUMBANKS = 2}
  7. {$SET PIC_NUMPAGES = 1}
  8. {$SET PIC_MAXFLASH = 2048}
  9. //Clear the RAM setting
  10. {$SET_STATE_RAM '000-1FF:NIM'}
  11. //Defines RAM state
  12. {$SET_STATE_RAM '000-00B:SFR, 00C-04F:GPR'}
  13. {$SET_STATE_RAM '080-08B:SFR, 08C-0CF:GPR'}
  14. //Defines mapped RAM
  15. {$SET_MAPPED_RAM '080-080:bnk0, 082-084:bnk0, 08A-08B:bnk0'}
  16. {$SET_MAPPED_RAM '08C-0CF:bnk0'}
  17. //Defines unimplemnted bits in RAM
  18. {$SET_UNIMP_BITS '003:3F,083:3F,005:1F,085:1F,00A:1F,08A:1F'}
  19.  
  20. {$FREQUENCY 4Mhz}
  21. begin
  22.  
  23. end.
  24.  
« Last Edit: November 07, 2017, 03:05:21 am by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #127 on: November 14, 2017, 03:08:17 pm »
PicPas has done again  :D. It's the best, optimizing the code size for the Mid-Range PIC, according to a new competition, against the best profesional compilers: https://github.com/AguHDz/PicPas-Librerias_y_Programas/tree/master/Compativa%20Compiladores%20II

Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #128 on: November 14, 2017, 03:29:31 pm »
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?


Compared to what? For me the 144 pins devices and crossbarswitch for peripherals in dspic (dspic33ep512mu814) allows me to make a generic board, and for experiments and test situations do a modular expansion 

I played with PIC32MK this summer, and rejected it. The CPU seems to be slower. (despite being a 120MHz over 70MHz, it feels like 40MHz)

bigbo

  • New member
  • *
  • Posts: 8
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #129 on: January 10, 2018, 11:58:48 pm »
Please reserve two more languages after German, I started to translate to Ukrainian and Russian.

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #130 on: January 11, 2018, 05:20:55 am »
Please reserve two more languages after German, I started to translate to Ukrainian and Russian.

OK, I will reserve space for Ukrainian and Russian.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #131 on: January 11, 2018, 10:53:23 pm »
Space added in the Source for Ukrainian and Russian languages.  :D

You can add the translation after the tags:
#uk=
#ru=

Is someone can add French, Italian or Portugues, please tell me.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

bigbo

  • New member
  • *
  • Posts: 8
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #132 on: January 12, 2018, 01:12:47 pm »
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.

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #133 on: January 12, 2018, 07:14:56 pm »
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.

Updated.  :D

Now PicPas (IDE and compiler) have translations to English, Spanish, German, Ukranian, Russian and quechua.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

bigbo

  • New member
  • *
  • Posts: 8
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #134 on: January 12, 2018, 11:43:20 pm »
This code from examples:

Code: Pascal  [Select][+][-]
  1. {Sample program to read a digital input
  2. in PORTB.4 and put the value in PORTB.5}
  3. {$FREQUENCY 4 MHZ }
  4. {$PROCESSOR PIC16F84A}
  5. program BlinkLed;
  6. var
  7.   PORTB : BYTE absolute $06;
  8.   TRISB : BYTE absolute $86;
  9.   //pin: bit absolute PORTB.7;
  10. begin                          
  11.   SetAsInput(PORTB.4);
  12.   SetAsOutput(PORTB.5);
  13.   while true do
  14.    //delay_ms(1);
  15.     PORTB.5 := PORTB.4;
  16.   end;
  17. end.

After I compiled I got this ASM code:

Code: Pascal  [Select][+][-]
  1.     list     p=16F84A
  2.     #include <p16F84A.inc>
  3. ;===RAM usage===
  4. PORTB EQU 0x006
  5. ;------ Work and Aux. Registers ------
  6. ;===Blocks of Code===
  7.     0x000 goto 0x001
  8. __main_program__:
  9.     ;SetAsInput(PORTB.4);
  10.     0x001 bsf 0x003, 5 ;Bank set.
  11.     0x002 bsf PORTB, 4
  12.     ;SetAsOutput(PORTB.5);
  13.     0x003 bcf PORTB, 5
  14.     ;PORTB.5 := PORTB.4;
  15.     0x004 bcf 0x003, 5 ;Bank set.
  16.     0x005 bcf PORTB, 5
  17.     0x006 btfsc PORTB, 4
  18.     0x007 bsf PORTB, 5
  19.     ;end;
  20.     0x008 bsf 0x003, 5 ;Bank set.
  21.     0x009 goto 0x004
  22. __end_program__:
  23.     ;end.
  24.     0x00A sleep  
  25. ;--------------------
  26.     END

Clear bit before checking?

Code: Pascal  [Select][+][-]
  1.     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
« Last Edit: January 13, 2018, 12:15:41 am by bigbo »

 

TinyPortal © 2005-2018