Recent

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

Edson

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

The address for the configuration word is assumed for the compiler. Each compiler know (or must know) the proper address:

* Baseline compiler -> Use $FFF
* Mid-range compiler -> Use $2007

For the Enhanced Mid-range compiler, we need to implement two addresses. No a big problem.
 
In the PicPas syntax, we can add a new directive, some like {$CONFIG2}
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Lulu

  • Full Member
  • ***
  • Posts: 226
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #181 on: June 09, 2018, 08:53:58 am »
Thanks for the precision.
« Last Edit: June 09, 2018, 11:05:58 am by Lulu »
wishing you a nice life

Lulu

  • Full Member
  • ***
  • Posts: 226
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #182 on: June 09, 2018, 08:14:33 pm »
Hello,
I finished the description file for PIC16F1454 !
Because it is my first, please Edson check it, particularly the 'SET_STATE_RAM' and 'SET_MAPPED_RAM' directive section.

On this PIC, there is the same common GPR block of 16 bytes which is repeated on each bank.
 I declared each of them with the SET_STATE_RAM directive. I do not know if this is good because it may give false information about the amount of RAM available. I don't know how your compiler treat this.
wishing you a nice life

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #183 on: June 10, 2018, 08:01:55 am »
Excelent!

This is the first hardware description of a Mid-range Enhanced Core CPU PIC.

It seems OK for me.  GPR and SFR are declared right with {$SET_STATE_RAM}

GPR is mapped OK with {$SET_MAPPED_RAM}

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.

A minor detail: Line 777 is:  // -- Bits Configuration Word 1 --
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.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Lulu

  • Full Member
  • ***
  • Posts: 226
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #184 on: June 10, 2018, 03:46:21 pm »
Excelent!

This is the first hardware description of a Mid-range Enhanced Core CPU PIC.
I'm happy to contribute !

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 --
Must be: // -- Bits Configuration Word 2 --
Corrected

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 !

Below, the updated file. Thanks !
wishing you a nice life

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #185 on: June 11, 2018, 06:16:20 am »
Hi. I've implemented an experimental compiler for the Enhanced Mid-range, family in PicPas  :). It's not complete by now, but can be used to test the units created. I have compiled the file PIC16F1454.pas and one errors is:

Line 4: {$SET PIC_MODEL    = PIC16F1454}
Must be: {$SET PIC_MODEL    = 'PIC16F1454'}

Other errors are in the lines of type:

{$SET_STATE_RAM '0000-000C:SFR'}

The compiler expect 3 digits for the address:

{$SET_STATE_RAM '000-00C:SFR'}

I don't see the necesity to increase the number of digits for this directive, considering 3 digits can cover all the 32 banks of RAM.

You can use the last version PicPas (in https://github.com/t-edson/PicPas) to test the units. Just set  the compiler to "Enhanced Mid-range", like in the picture:
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 #186 on: June 11, 2018, 09:11:44 pm »
Hi. The user https://github.com/cuistax confirmed he has created the units for the Enhanced Mid-range family. Maybe we are duplicating the work. Let's wait until I can check his units.
What we are going to need additionally, is "test code" for the compiler and some ASM routines for math operations.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Lulu

  • Full Member
  • ***
  • Posts: 226
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #187 on: June 11, 2018, 09:56:44 pm »
Hi, ok I stop the work on the units. Cuistax did a lot of work !
wishing you a nice life

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #188 on: June 12, 2018, 06:51:23 am »
Hi, ok I stop the work on the units. Cuistax did a lot of work !

Yes. Cuistax has written more than 200 units for the Baseline, Mid-range and Enhanced Mid-range devices. We have now more devices definitions that the compiler can support.

The new units for the Enhanced Mid-range are now available in the GitHub. I need to finish the compiler PIC17 (Enhanced Mid-range compiler), but by the moment I'm working in automate the testing for the compiler, because  now we have 3 compilers and hundreds of files to test.

The automation of tests I've projected, needs to improve the simulator and that's where I'm working now.  The compiler PIC10 (Baseline compiler) is not well tested.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

piGrimm

  • Guest
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #189 on: June 12, 2018, 02:55:26 pm »
cool! BUT
due to the lack of file formats support, I will still use
https://www.freecadweb.org
because it is simply awesome
https://www.freecadweb.org/wiki/Import_Export << files formats

Lulu

  • Full Member
  • ***
  • Posts: 226
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #190 on: June 12, 2018, 10:05:59 pm »
cool! BUT
due to the lack of file formats support, I will still use
https://www.freecadweb.org
because it is simply awesome
https://www.freecadweb.org/wiki/Import_Export << files formats
I think this is not the subject of this topic... Here we discuss about Edson compiler for Microchip PIC microcontrollers !

@Edson, I will take a look at the git

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?
« Last Edit: June 12, 2018, 10:34:34 pm by Lulu »
wishing you a nice life

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #191 on: June 13, 2018, 06:53:20 am »
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?

Yes. It's the secure way to declare a mapped RAM section what is SFR. Currently the compiler doesn't uses the mapping information for the SFR, but it's planned to use this information in the future for optimization features.

Currently, if you only declare a RAM section like mapped but don't define the state, it will be assumed like "Unimplemented" RAM.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Lulu

  • Full Member
  • ***
  • Posts: 226
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #192 on: June 13, 2018, 07:26:15 pm »
Thank you for the details. I have checked the file PIC16F1825.pas in 'devices17', and it seems to miss some state definition on mapped SFR areas. The cores registers are repeated in each bank but only the INDF register is declared with SET_STATE_RAM. The SET_MAPPED_RAM section seems to be well defined.
I wrote a message to Cuistax on GitHub.

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.
« Last Edit: June 13, 2018, 08:12:57 pm by Lulu »
wishing you a nice life

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #193 on: June 13, 2018, 10:13:15 pm »
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.
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 #194 on: June 13, 2018, 10:19:05 pm »
PicPas 0.8.7 is closed and released now.  :D https://github.com/t-edson/PicPas
Binaries have been updated for Windows, Linux and Mac.

Most of the changes have been done in the debugger/simulator.

Now PicPas can simulate the PIC including some components for input and output:

New changes will be in the trunk version 0.8.8.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018