Recent

Author Topic: Why no Freepascal for Arduino?  (Read 1401 times)

coradi

  • Full Member
  • ***
  • Posts: 185
Why no Freepascal for Arduino?
« on: October 08, 2025, 02:47:09 pm »
Arduino ist open Source, and the Software too.
So it will maybe, not a big problem to convert all Libs and defination files for all Controllers to pascal
Amstrad Schneider CPC 6128
AVR8/ARM(STM32)

Dzandaa

  • Hero Member
  • *****
  • Posts: 501
  • From C# to Lazarus
Re: Why no Freepascal for Arduino?
« Reply #1 on: October 08, 2025, 04:11:50 pm »
Hi,

Have a look at AVRPascal fro Andrzej

https://akarwowski.pl/index.php?page=electronics&lang=en

I use it as a companion to Pascal Lazarus, so I stay in the same programming language.

B->
Regards,
Dzandaa

paweld

  • Hero Member
  • *****
  • Posts: 1494
Re: Why no Freepascal for Arduino?
« Reply #2 on: October 08, 2025, 04:15:32 pm »
I am not familiar with this topic, but it seems to me that FPC trunk (3.3.1 aka main) already supports the AVR target.
You can find threads on this topic on the forum in the category: https://forum.lazarus.freepascal.org/index.php/board,78.0.html

You can find many examples in the @ccrause repository: https://github.com/ccrause/fpc-avr

There is even an IDE for programming microcontrollers written in FPC by user @ackarwow: https://akarwowski.pl/index.php?page=electronics&lang=en
Best regards / Pozdrawiam
paweld

coradi

  • Full Member
  • ***
  • Posts: 185
Re: Why no Freepascal for Arduino?
« Reply #3 on: October 08, 2025, 04:22:56 pm »
Yes, but is hard to do, because there are no defination files or only for a handfull Controllers and much more complicatet.
But Freepascal can convert ALL from Arduino and can use the same commands as Arduino.
By the way, I never got it running with Freepascal deluxe too:-(
Amstrad Schneider CPC 6128
AVR8/ARM(STM32)

Thaddy

  • Hero Member
  • *****
  • Posts: 18324
  • Here stood a man who saw the Elbe and jumped it.
Re: Why no Freepascal for Arduino?
« Reply #4 on: October 08, 2025, 06:08:01 pm »
I don't understand the "Why no Freepascal for Arduino?" part, because it is easy to build a cross-compiler for arduino.
And has been for quite a few years.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

coradi

  • Full Member
  • ***
  • Posts: 185
Re: Why no Freepascal for Arduino?
« Reply #5 on: October 08, 2025, 06:30:42 pm »
Libs and defination files convert from arduino to freepascal, so you can youese freepascal for easy programming, like arduiono.
At this moment there are no def files like arduino and no liba for any Temp Sensor, TFT, LCD and so on
At this time it is hard to program with freepascal, because you have to do all bare metal
Amstrad Schneider CPC 6128
AVR8/ARM(STM32)

Thaddy

  • Hero Member
  • *****
  • Posts: 18324
  • Here stood a man who saw the Elbe and jumped it.
Re: Why no Freepascal for Arduino?
« Reply #6 on: October 08, 2025, 06:46:41 pm »
What is hard? Translate a datasheet?
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

coradi

  • Full Member
  • ***
  • Posts: 185
Re: Why no Freepascal for Arduino?
« Reply #7 on: October 08, 2025, 07:07:37 pm »
Yes, for example.
Who can write a driver for a TFT if they don't know how to program well?
The Arduino libraries that come with it make everything very easy, but it's still C/C++ with all its difficulties.

Code: Pascal  [Select][+][-]
  1. int sensorPin = A0;   // select the input pin for the potentiometer
  2. int ledPin = 13;      // select the pin for the LED
  3. int sensorValue = 0;  // variable to store the value coming from the sensor
  4.  
  5. void setup() {
  6.   // declare the ledPin as an OUTPUT:
  7.   pinMode(ledPin, OUTPUT);
  8. }
  9.  
  10. void loop() {
  11.   read the value from the sensor:
  12.   sensorValue = analogRead(sensorPin);
  13.   digitalWrite(ledPin, HIGH);
  14.   delay(sensorValue);
  15.   digitalWrite(ledPin, LOW);
  16.   delay(sensorValue);
  17. }
« Last Edit: October 08, 2025, 07:09:14 pm by coradi »
Amstrad Schneider CPC 6128
AVR8/ARM(STM32)

Dzandaa

  • Hero Member
  • *****
  • Posts: 501
  • From C# to Lazarus
Re: Why no Freepascal for Arduino?
« Reply #8 on: October 08, 2025, 07:23:04 pm »
Hi
@coradi:

Here is the code for the "blink" program using AVRPascal:

Code: Pascal  [Select][+][-]
  1. program TestBlink;
  2.  
  3. {$IF NOT (DEFINED(atmega328p) or DEFINED(arduinouno) or DEFINED(arduinonano) or DEFINED(fpc_mcu_atmega328p) or DEFINED(fpc_mcu_arduinouno) or DEFINED(fpc_mcu_arduinonano))}
  4.  {$Fatal Invalid controller type, expected: atmega328p, arduinouno, or arduinonano}
  5. {$ENDIF}
  6.  
  7. {$mode objfpc}
  8.  
  9. uses
  10.   defs, timer, digital;
  11.  
  12. const
  13.   LedPin = 13; //internal LED
  14.  
  15. begin
  16.   PinMode(LedPin, OUTPUT);
  17.   DigitalWrite(ledPin, LOW);
  18.  
  19.   while True do
  20.   begin
  21.     DigitalWrite(ledPin, HIGH);
  22.     Delay(1000);
  23.     DigitalWrite(ledPin, LOW);
  24.     Delay(1000);
  25.   end;
  26. end.
  27.  
  28.  

Not very complicated.

B->
Regards,
Dzandaa

coradi

  • Full Member
  • ***
  • Posts: 185
Re: Why no Freepascal for Arduino?
« Reply #9 on: October 08, 2025, 07:26:23 pm »
does AVRF pascal work with STM32?
Does AVR PAscal habe the same lib for nearly any sensor and TFT?!
Does AVRPAscal work with ESp32?
...

But yess, I didn' know avrpascal:-)
It look nice:-)
https://akarwowski.pl/index.php?page=electronics&lang=en
« Last Edit: October 08, 2025, 07:39:04 pm by coradi »
Amstrad Schneider CPC 6128
AVR8/ARM(STM32)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12524
  • FPC developer.
Re: Why no Freepascal for Arduino?
« Reply #10 on: October 08, 2025, 08:39:06 pm »
Arduino is basically rebadged posix.

Not so much that it is an unix standard, but that it is mostly a trademark(tm) that means nothing but a vague promise of compatibility if you recompile a compliant source for a supported target with a approved tool.

And usually anything outside of the "compliant,supported,approved" bit fails or is badly supported.

LeP

  • Jr. Member
  • **
  • Posts: 57
Re: Why no Freepascal for Arduino?
« Reply #11 on: October 08, 2025, 09:48:26 pm »
I think all of you must wait ....
Yesterday the Qualcomm company has bought the Italian company owner of Arduino.

From October 25, new "Arduino UNO Q" with SnapDragon processor is going to be available.


ccrause

  • Hero Member
  • *****
  • Posts: 1080
Re: Why no Freepascal for Arduino?
« Reply #12 on: October 09, 2025, 03:17:44 pm »
I am not familiar with this topic, but it seems to me that FPC trunk (3.3.1 aka main) already supports the AVR target.
8 bit AVR support was first released with FPC 3.0 and became much more usable with release 3.2.  Obviously main contains more fixes & features (and the risk of a new bug or two).

ccrause

  • Hero Member
  • *****
  • Posts: 1080
Re: Why no Freepascal for Arduino?
« Reply #13 on: October 09, 2025, 03:36:24 pm »
But Freepascal can convert ALL from Arduino and can use the same commands as Arduino.
Unolib is a project doing more or less exactly this.  But it takes time and effort to translate libraries, so it will happen gradually.  Unolib only have a few libraries at the moment but a lot of the low level functionality is implemented, so pick your favourite Arduino library and contribute a Pascal translation.

paweld

  • Hero Member
  • *****
  • Posts: 1494
Re: Why no Freepascal for Arduino?
« Reply #14 on: October 09, 2025, 04:14:49 pm »
Quote from: ccrause
8 bit AVR support was first released with FPC 3.0 and became much more usable with release 3.2.  Obviously main contains more fixes & features (and the risk of a new bug or two).
Thank you very much for the explanation. I just took a quick look at the compilation example in your repository, and based on that, I drew the (incorrect) conclusion.
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018