Recent

Author Topic: AVRPascal – free code editor for FPC for AVR  (Read 42459 times)

ccrause

  • Hero Member
  • *****
  • Posts: 1093
Re: AVRPascal – free code editor for FPC for AVR
« Reply #150 on: August 03, 2025, 10:54:07 am »
@ccrause,
Yes, it is possible. I modified slightly usb.pas to be more compatible with Arduino source (attached) but I'm not sure if it will help. Have you tried writing a similar test program to the Arduino Sketch to make sure that Arduino code is working correctly? What are the connections in your test environment (I mean hardware and circuit)?

PS. I am using Arduino 1.8.19

I'm using a Leonardo board for testing.  To test the hardware serial I use a USB-serial converter connected to pins 0 and 1 (not that the hardware serial should be a consideration here).  Below an Arduino sketch that works as expected (built in Arduino 1.8.15):
Code: C  [Select][+][-]
  1. #define LEDpin 8
  2.  
  3. void setup() {
  4.   // On Leonardo this is the USB-CDC serial:
  5.   Serial.begin(9600);
  6.   while (!Serial) {}
  7.  
  8.   pinMode(LEDpin, OUTPUT);
  9.   digitalWrite(LEDpin, HIGH);
  10. }
  11.  
  12. void loop() {
  13.   if (Serial.available() > 0) {
  14.     digitalWrite(LEDpin, !digitalRead(LEDpin));
  15.     Serial.write(Serial.read());
  16.   }
  17. }

PS: I typically use CuteCom as serial monitor on Linux, and I noticed that if the RTS and DTR signals are disabled then the Arduino CDC serial does not write to host, because of the lineState check in the code.  Same gotcha in GTKTerm.  Ensure that either DTR or RTS is set in the receiving client's serial setup when expecting USB-CDC serial data from the Arduino implementation.

ccrause

  • Hero Member
  • *****
  • Posts: 1093
Re: AVRPascal – free code editor for FPC for AVR
« Reply #151 on: August 03, 2025, 11:23:22 am »
I modified slightly usb.pas to be more compatible with Arduino source (attached) but I'm not sure if it will help.

Tested the new usb.pas, same problem with sending data from Leonardo.

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #152 on: August 03, 2025, 11:43:46 pm »
@ccrause,
Here are corrected version of usb.pas and my test program. Sending data to USB should work.

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #153 on: August 17, 2025, 07:00:46 pm »
A new version of AVRPascal (3.3) has been released.
As always, it's available for download on my webpage (http://akarwowski.pl/index.php?page=electronics&lang=en).

Changes:

New version of UnoLib (1.1, see https://sourceforge.net/projects/unolib/ for details)
New features:
- added the "Add conditional directive for current device" option to the New File dialog box
- automatic renaming of the program/unit name after saving a file with a new name
- new options in Serial Port Monitor window: "line ending" (No, NL, CR, NL&CR) and "mode" (Ascii, Hexadecimal) (thanks to @Dzandaa for suggestions)
- improved installer for Linux, now AVRPascal appears in "Programming" section (thanks to @Dzandaa for suggestions) 
Bug fixes:
- fixed problems with reading data in Serial Port Monitor (thanks to Christof Biner for detailed description of the problem)
- minor aesthetic changes in Upload window

The PDF manual will be updated in a few days.

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #154 on: August 24, 2025, 10:00:55 am »
The manual, updated with the new features of AVRPascal 3.3, is available on my website.
I have also prepared a short "How to start" guide for beginners (attached). Please let me know if anything is missing or needs to be corrected.

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #155 on: August 26, 2025, 06:19:23 pm »
AVRPascal now is also on Reddit (https://www.reddit.com/r/avrpascal/). I invite everyone interested in news and discussion about this program. :)

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #156 on: November 14, 2025, 04:21:44 pm »
A new version of AVRPascal (3.4) has been released. As always, it is available for download on my webpage (https://akarwowski.pl/index.php?page=electronics&lang=en) or via dedicated domain (https://avrpascal.org).

Changes:

New version of UnoLib (1.2, see https://sourceforge.net/projects/unolib/ for details)
- UnoLib documentation has been added to the "docs" directory

New features and updates:
- the "Image Information" window has been moved to the debugger plugin (AVRPascalDbg); a brief note about flash memory usage now appears in the "Messages" area after successful compilation
- a "Data Converter" window has been added, allowing for the conversion of decimal floating-point numbers to their hexadecimal/binary representation in IEEE-754 and Q16.16 formats, useful when using the TFloat32 and TFix16 types from UnoLib
- changed default parameters: font size (10), tab size (2), and clock frequency definition (F_CPU) (now selected)
- added a "Serial Monitor" button to the toolbar (thanks to @Dzandaa for the suggestion!)
- updated the Readme.txt file with the new licence

Bug fixes:
- fixed the "Check for updates" and "Send to Manufacturer" functions following the change in the akarwowski.pl website protocol (from http to https)

I look forward to your feedback and questions. :)

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #157 on: December 15, 2025, 10:40:17 pm »
I'm glad to announce the release of AVRPascal IDE 3.5. Key changes:

1. New port for FreeBSD 13 (64-bit, PKG installer)
2. New portable ZIP package for Linux (designed for creating custom installers for non-officially supported distributions)
3. New features and updates:
 - improved detection of blocking directives to handle more complex constructions (option "Detect controller type in IFNDEF directive")
 - improved the functionality of "Search" / "Replace," adding the "from cursor" option and a prompt to search again (thanks to @Dzandaa for the suggestion)
 - the program now opens in a single instance, which prevents accidental overwriting of the configuration file (INI)
 - code refactoring was performed, resulting in a significant reduction of the executable file size (Windows: 71 MB -> 60 MB, Linux: 55 MB -> 49 MB, MacOS: 31 MB -> 20 MB, FreeBSD: 96 MB -> 81 MB)
4. Bug Fixes:
 - fixed an issue with pasting data from the clipboard into the decimal numeric field in the "Data Converter" window (thanks to @Dzandaa for the suggestion)

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #158 on: December 25, 2025, 06:14:16 pm »
I have just published the first lesson of the "AVR Microcontroller Engineering with Pascal" course.

Here's what's included:
- Target: ATtiny13.
- Goal: Building our own "Arduino replacement" from scratch.
- Method: Pure "bare-metal" programming using registers (DDRB, PORTB) – no libraries, just clean Pascal code.
- Simplicity: Controlling hardware can be done with practically just two lines of code.

The lesson is available as a PDF on my website (https://akarwowski.pl/index.php?page=electronics&lang=en). Have fun :)

ccrause

  • Hero Member
  • *****
  • Posts: 1093
Re: AVRPascal – free code editor for FPC for AVR
« Reply #159 on: December 26, 2025, 07:32:29 am »
Nice tutorial!  This is probably intended as a short tutorial, however I think there are some extra notes that can be included as background:
  • The circuit as shown will only work with a programmer attached.  This is of course the lowest parts count solution, but maybe add a discussion on what is required to make this a standalone project not connected to the USBASP (power connections, bypass capacitor requirements, function of PB5/RESET and why a pullup resistor is required in general).
  • The required fuse settings to use PB5 as digital IO is not discussed. The default fuse setting from factory is that PB5 functions as the chip's reset pin. I would not suggest changing the reset pin to IO mode, since that will then require high voltage programming.
  • I suggest adding a pulldown resistor to the MOSFET's gate, since it has some capacitance that could keep the MOSFET switched on when the gate voltage is removed.
  • Regarding the programming header IDC10 connector: perhaps also mention that a 6 pin variant exists.
  • Minor issue, calling the program "blink" when its purpose is just to switch the LED on is misleading  ;)
  • Correction: the internal RC oscillator operates at nominally 9.6  or 4.8 MHz
  • Suggestion for next tutorial: add momentary switch and read switch state to toggle LED on/off. Requires a discussion of pull-up or pull-down pins, internal/external resistors, mechanical switch debouncing etc.

These kind of projects where the user both build circuits and write firmware requires background knowledge of both electronics, programming and the microcontroller itself. Of course the difficulty is to present the correct balance of topics to not bore or confuse a new user.

Keep up the good work!

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #160 on: December 26, 2025, 11:33:50 am »
Many thanks for your feedback, @ccrause! Regarding your points:

The circuit as shown will only work with a programmer attached.  This is of course the lowest parts count solution, but maybe add a discussion on what is required to make this a standalone project not connected to the USBASP (power connections, bypass capacitor requirements, function of PB5/RESET and why a pullup resistor is required in general).
Of course. I will clarify that this setup relies on the programmer for power. Making stand-alone device is probably a good idea for one of the next lessons to not complicate the issue for absolute beginners.

The required fuse settings to use PB5 as digital IO is not discussed. The default fuse setting from factory is that PB5 functions as the chip's reset pin. I would not suggest changing the reset pin to IO mode, since that will then require high voltage programming.
Yes, thank you. I will add this information as a footnote. Without the transistor, I agree it's much better to leave PB5 solely for reset purposes to avoid the need for high-voltage programming.

I suggest adding a pulldown resistor to the MOSFET's gate, since it has some capacitance that could keep the MOSFET switched on when the gate voltage is removed.
You are right about the gate capacitance. I will consider adding a footnote about that to keep the hardware setup as simple as possible for the first lesson. Re-doing all the photographs and diagrams for a non-critical (in this specific setup) resistor would be a huge task, but I think a technical note will be good enough.

Regarding the programming header IDC10 connector: perhaps also mention that a 6 pin variant exists.
Yes, that's another excellent point for a footnote.

Minor issue, calling the program "blink" when its purpose is just to switch the LED on is misleading  ;)
Yes. The program should be named "LEDOn" or in similar way :)

Correction: the internal RC oscillator operates at nominally 9.6  or 4.8 MHz
Yes, that's a good technical detail to include in a footnote.

Suggestion for next tutorial: add momentary switch and read switch state to toggle LED on/off. Requires a discussion of pull-up or pull-down pins, internal/external resistors, mechanical switch debouncing etc.
Actually, most of your suggestions for the next lesson (like internal pull-ups, debouncing, and button handling) are already covered in Lesson 3 of the course. I have already published it in Polish (there are 4 lessons at the moment), and the English translation is on the way.

Thank you again for your comments, I will take them into account in the next version of the lesson.

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #161 on: December 27, 2025, 12:30:23 pm »
Hi everyone, here is the updated version of Lesson 1 :) Many thanks to @ccrause.

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #162 on: January 17, 2026, 10:57:09 am »
Hi everyone,

I’ve finished the English translation of Lesson 2 of “AVR Microcontroller Engineering with Pascal”.
The PDF and the source code in ZIP format are attached.

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 720
Re: AVRPascal – free code editor for FPC for AVR
« Reply #163 on: January 18, 2026, 08:58:42 pm »
Bought a $1 clone Arduino Nano module to give AVRPascal a try.  Works great! 

My cookbook once a program's .hex file has been created (the example TestBlink.Pas provided is an excellent place to start).

Navigate to View>Options>Uploader
Set Verbosity 4 (just to see what happens -- change it to something else later)
Set Define baud rate 57600  (Important to be able to connect to my clone Nano module)
Check the Define baud rate check box
Check Show command line check box
In "Supported USB devices" list, select Arduino Nano
Click OK
Navigate to Run>Upload
Set Port to /dev/ttyUSB0
Set Device ATmega328P
Click OK

Thank you ackarwow -- looking forward to playing with this!
(Hope I recorded the steps correctly)

ackarwow

  • Full Member
  • ***
  • Posts: 173
    • Andrzej Karwowski's Homepage
Re: AVRPascal – free code editor for FPC for AVR
« Reply #164 on: January 18, 2026, 10:18:12 pm »
Bought a $1 clone Arduino Nano module to give AVRPascal a try.  Works great! 

My cookbook once a program's .hex file has been created (the example TestBlink.Pas provided is an excellent place to start).

Navigate to View>Options>Uploader
Set Verbosity 4 (just to see what happens -- change it to something else later)
Set Define baud rate 57600  (Important to be able to connect to my clone Nano module)
Check the Define baud rate check box
Check Show command line check box
In "Supported USB devices" list, select Arduino Nano
Click OK
Navigate to Run>Upload
Set Port to /dev/ttyUSB0
Set Device ATmega328P
Click OK

Thank you ackarwow -- looking forward to playing with this!
(Hope I recorded the steps correctly)

Hi Curt,

Thank you for your feedback - this is especially valuable for Arduino Nano clone users. I may add a short dedicated section to the FAQ based on your findings.

In fact, this is a good result of your experience and the solid foundations provided by FPC and avrdude, which AVRPascal uses. :)

Good finding, and thank you for sharing your solution!

 

TinyPortal © 2005-2018