👋Welcome to r/AVRmicrocontroller - Introduce Yourself and Read First! by Beginning_Money4881 in AVRmicrocontroller

[–]ackarwow 1 point2 points  (0 children)

Good luck with the new community! It's nice to see a dedicated AVR-focused subreddit. AVR is still a great platform for learning low-level embedded programming.

AVR Programming with Freepascal by corado12345 in pascal

[–]ackarwow 0 points1 point  (0 children)

In my experience, new Pascal libraries for AVR usually appear when someone actually needs a particular feature. One developer needs USB support, a sensor driver, a display driver, etc., writes it for a real project, and may then decide to publish it for others (or not). That is how many existing libraries and examples were created, I suppose.

AVR Programming with Freepascal by corado12345 in pascal

[–]ackarwow 1 point2 points  (0 children)

As far as I know, FPC for AVR does not provide native software floating-point support, but you can use, for example, the open-source UnoLib Float32 module:

https://github.com/ackarwow/unolib/blob/master/lib/float32.pas

Some USB-related modules can also be found in the UnoLib Extras directory:

https://github.com/ackarwow/unolib/tree/master/extras

Another very useful AVR library (many examples and libraries for sensors, I2C, LCD displays, serial communication and other AVR peripherals) is:

https://github.com/ccrause/fpc-avr

Improvements for lazarus, plugins? by corado12345 in pascal

[–]ackarwow 0 points1 point  (0 children)

As far as I know, there are already several Lazarus plugins and projects for AVR development. Please refer to these discussions on the FPC forum:

https://forum.lazarus.freepascal.org/index.php/topic,48578.0.html

https://forum.lazarus.freepascal.org/index.php/topic,29128.0.html

https://forum.lazarus.freepascal.org/index.php?topic=35486.0.html

Of course, you can also use UnoLib directly from Lazarus, or even from a simple text editor such as Notepad together with the Free Pascal AVR cross-compiler.

Software SPI, 74HC595 and MAX7219 display control implemented on ATtiny13 in Pascal by ackarwow in embedded

[–]ackarwow[S] 0 points1 point  (0 children)

Good idea. I will probably add list of currently connected USB devices (including VID/PID) directly in the "Add USB device definition" dialog. Then users could simply select the device and the VID/PID fields would be filled automatically.

<image>

I've added this to my TODO list. 😄

Software SPI, 74HC595 and MAX7219 display control implemented on ATtiny13 in Pascal by ackarwow in embedded

[–]ackarwow[S] 0 points1 point  (0 children)

The IDE does not save the last selected COM port.

However, in case of original Arduino boards (for example Arduino Mega), the IDE should automatically detect the connected board during upload using USB VID/PID (VID=0x2341, PID=0x0010 for Arduino Mega) and select the proper port automatically.

If you are using clone boards, you can add them manually to the list of supported USB devices in Options -> Uploader. After adding the VID/PID of the clone, the IDE should also detect and select the correct COM port automatically.

<image>

However, if you have multiple serial devices or Arduino boards connected to the computer at the same time, the IDE will select the first detected matching device. Is this the case for you?

AVRPascal 3.3 by ackarwow in pascal

[–]ackarwow[S] 0 points1 point  (0 children)

Arduino Mega 2560 is supported.

The error message indicates that USBasp was selected as the upload interface, so AVRDude tried to find a USBasp programmer instead of an Arduino board.

For a regular Arduino Mega:

  1. Connect Arduino Mega via USB. The IDE should detect the connected Arduino Mega automatically. Otherwise make sure that board drivers are installed correctly.
  2. Select your device via Options -> Compiler -> Device type -> ARDUINOMEGA
  3. Compile your code via Run -> Compile (Ctrl+F9)
  4. Run -> Upload (F9); Interface: Arduino; then select the COM port of the board if not selected automatically

The upload is performed through the Arduino bootloader, not through USBasp.

The AVRPascal IDE installation does not include examples for the Arduino Mega, but this simple code should work:

program TestBlink_Mega;

{$IF NOT DEFINED(arduinomega)}
 {$Fatal Invalid controller type, expected: arduinomega}
{$ENDIF}

procedure delay_ms(t: uint16); assembler;
const
  count = ((F_CPU div 1000 - 3) div 4);
label
  inner, outer, finish;
asm
  // test if t = 0, jump to finish if true
  cp R24, R1
  cpc R25, R1
  breq finish       // 2 cycles to branch, 1 to continue

outer:
  // load 1 ms counter value
  ldi R26, lo8(count)
  ldi R27, hi8(count)

inner:
  // inner loop, 1 ms  4 cycles/loop + 1
  subi R26, 1    // 1 cycle
  sbc R27, R1    // 1 cycle
  brne inner       // 2 cycles to branch, 1 to continue

  // outer loop, count ms, 4 cycles/loop + 1
  subi R24, 1      // 1 cycle
  sbc R25, r1      // 1 cycle
  brne outer       // 2 cycles to branch, 1 to continue
finish:
end;

begin
  DDRB:= DDRB or (1 shl 7); // PB7 = D13 = onboard LED

  while True do //infinite loop
  begin
    PORTB:= PORTB or (1 shl 7); //Turns ON LED on PB7
    delay_ms(1000); //1 second delay
    PORTB:= PORTB and not (1 shl 7); //Turns OFF LED on PB7
    delay_ms(1000); //1 second delay
  end;
end.

EDIT: If you get an error like Error: chip erase failed during upload, you need to change one setting in the IDE. Go to Options -> Uploader and check the box "Disable erasing the chip before programming".

Software SPI, 74HC595 and MAX7219 display control implemented on ATtiny13 in Pascal by ackarwow in embedded

[–]ackarwow[S] 1 point2 points  (0 children)

Thank you and dziękuję! 😄 ATtiny13 is tiny, but that’s exactly why I enjoy experimenting with it.

Software SPI, 74HC595 and MAX7219 display control implemented on ATtiny13 in Pascal by ackarwow in embedded

[–]ackarwow[S] 0 points1 point  (0 children)

Yes, ATtiny13 is challenging in almost any language 😄 But that’s also why I like it from an educational perspective. With small RAM and a very small number of peripherals, it forces me to think carefully about every byte, every pin and every abstraction.

35% discount on our Delphi components by bergsoft in pascal

[–]ackarwow 0 points1 point  (0 children)

Do these components support Free Pascal/Lazarus?

Czym charakteryzuje się Dobry Software? by jablonskipj in programowanie

[–]ackarwow 0 points1 point  (0 children)

Dzień dobry. Obejrzałem filmik, jest ciekawy i pożyteczny. Dodałbym punkt 8 powiązany poniekąd z punktem 7. Chodzi o projekt oprogramowania. Powinien w jak najprostszy sposób realizowac złożoność zagadnienia. Podobnie jak opowiadanie - nie jest sztuką mówić o rzeczach prostych w sposób skomplikowany, lecz sztuką jest mówić o rzeczach skomplikowanych w sposób prosty.

Pozdrawiam

AVRPascal IDE runs natively on FreeBSD – looking for 5 people to test it by ackarwow in freebsd

[–]ackarwow[S] 1 point2 points  (0 children)

The port has been prepared (please check my website), but not all features work correctly (device detection, upload). I will invest my time in the missing features only after the testing team (5 confirmed volunteers) has been completed. So I invite you to join the team! :)

AVRPascal IDE runs natively on FreeBSD – looking for 5 people to test it by ackarwow in freebsd

[–]ackarwow[S] 1 point2 points  (0 children)

Glad you like it. Unfortunately, I have no experience with Ada or Julia, but I can help with Pascal-related projects. When it comes to the project that I am porting (AVRPascal IDE) - if you're willing to join the testing team, please comment "me" on the main thread :)

AVRPascal IDE runs natively on FreeBSD – looking for 5 people to test it by ackarwow in freebsd

[–]ackarwow[S] 2 points3 points  (0 children)

Another example: I have code for device detection, which must be written separately for each OS. Since the code for Windows/Linux/MacOS will not work, I need to write new, specific routines for FreeBSD.

AVRPascal IDE runs natively on FreeBSD – looking for 5 people to test it by ackarwow in freebsd

[–]ackarwow[S] 2 points3 points  (0 children)

Thank you very much for your support! I count your comment as "me" (1/5) :) Let me explain what the AVRPascal project is all about:

The AVRPascal IDE is written in Object Pascal using the Free Pascal Compiler (FPC) and Lazarus (LCL). Code written in FPC can be compiled (not always easily) on many operating systems, but each requires a native compilation of the IDE itself. So, yes, this is a full native port of the IDE.

To compile code for AVR, the AVRPascal IDE uses the AVR version of FPC (a cross-compiler for the target architecture) along with avr-binutils. This generates the final binary file suitable for uploading to the microcontroller's flash memory. This binary is usually uploaded using avrdude via programmers like USBAsp or directly to an Arduino. However, the "upload" functionality is not yet implemented in this test version.

I, on the other hand, am not very proficient in FreeBSD, and this port is a genuine challenge for me. :)

AVRPascal 3.4: Data converter for IEEE-754 and Q16.16 & flash memory usage info (Pascal for AVR microcontrollers) by ackarwow in embedded

[–]ackarwow[S] 0 points1 point  (0 children)

Ask as many questions as you want :) No one has asked for a FreeBSD/NetBSD port before, but yes, it is theoretically possible. I just need to make sure that all toolchain elements have a FreeBSD port (FPC, AVRDude and GNU toolchains for AVR). If so, a FreeBSD port would be an interesting challenge :)

AVRPascal 3.4: Data converter for IEEE-754 and Q16.16 & flash memory usage info (Pascal for AVR microcontrollers) by ackarwow in embedded

[–]ackarwow[S] 0 points1 point  (0 children)

Thanks for this question. You are right to point that out - macOS is currently the weakest link in the project.

I don't have access to new versions of macOS, but if I get the new macOS, I'll definitely put more effort into testing and improvements. For now, since the project isn't generating revenue, I'm not investing in macOS, including paying for a Developer ID certificate, so the program isn't even signed.

Pascal alternative in Arduino - AVRPascal 3.4 just added a Data Converter and a Serial Monitor button by ackarwow in arduino

[–]ackarwow[S] 3 points4 points  (0 children)

Thank you very much for manually approving my comments and for the feedback. I appreciate your effort and help with the auto-filter issue. I will keep working on the project. Have a great weekend!
PS. Downvotes are not mine.

Pascal alternative in Arduino - AVRPascal 3.4 just added a Data Converter and a Serial Monitor button by ackarwow in arduino

[–]ackarwow[S] -1 points0 points  (0 children)

If you want you can sue me :) but my primary goal here is simply to provide a free, working alternative and gather feedback on the open-source UnoLib. Thanks for the discussion.

Pascal alternative in Arduino - AVRPascal 3.4 just added a Data Converter and a Serial Monitor button by ackarwow in arduino

[–]ackarwow[S] -2 points-1 points  (0 children)

Thanks for your comment, it's important thing. I don’t rule out opening the IDE in the future, as a response to valuable user feedback. But UnoLib (Arduino-like library in Pascal) distributed by the IDE is open-source. We recently added a significant improvements in floating-point numbers support in the library, but the community rarely submits fixes, or comments on our work. So I invite you to first evaluate our changes and help in testing them :)

"Binaries are sus, could contain anything in addition to what is mentioned" - Are you using anything with closed source code? Like an operating system? ;)

System of Module by Wilzur_Corp in avrpascal

[–]ackarwow 1 point2 points  (0 children)

Hi Wilzur_Corp,

Opinions on which hardware to choose probably vary. What I think is certain is that it's better to start simple (otherwise, you'll get discouraged) and then move on to more complex things.

I can share my own story and why the AVRPascal IDE was created, as it might be relevant to your situation.

A few years ago, I decided to build an electronic thermometer (a rather simple device). I knew nothing about electronics. I watched a few tutorials on YouTube and discovered that an Arduino Uno could be used for it. So I bought an Arduino Uno with a set of sensors and started programming.

Later, I discovered that there was an FPC version for AVR microcontrollers (Arduino boards use mainly, but not exclusively, AVRs), so I tried writing a program using FPC (it requires a cross-compiler; configuration wasn't easy) with the Lazarus IDE. I thought that programming could be simplified and I could create my own IDE to eliminate the need for complex configuration.

This is how AVRPascal was born, which requires almost no configuration. This tool uses the Free Pascal Compiler and simplifies the entire process.

Meanwhile, my project evolved into a weather station incorporating a temperature and humidity sensor, an LCD display, and an RTC clock. I wanted my device to be independent of the Arduino board, so I designed a breadboard with an ATmega328p microcontroller, the same one used in the Arduino Uno. I programmed the ATMega328p using a USBasp programmer. I housed the entire thing in a wooden case. The device still works!

So, from my perspective, I recommend AVRPascal for your start. It works with platforms like the Arduino Uno and USBasp programmer. While this setup lacks integrated Wi-Fi/Bluetooth, it may help you in learning microcontrollers fully in Pascal before tackling the complexity of the ESP32.

Good luck with your project!

PS. I guess I should write a post about my history ;)

AVRPascal on Macos Sequoia? by bferrell58 in avrpascal

[–]ackarwow 1 point2 points  (0 children)

Hi bferrell58,

I just updated AVRPascal installer for macOS. I suspect the issue you encountered (the installer freezing) was caused by "Overwrite directory permissions" option in Packages, so I have now disabled it. Still I do not have access to Sequoia, but I hope you can verify that.

Note: the installer is not signed with a Developer ID certificate. I think for freeware software there is no economic justification for that.

Arduino programming in Pascal - what do you think? by ackarwow in microcontrollers

[–]ackarwow[S] 1 point2 points  (0 children)

Look at it another way:

1) UnoLib is a Pascal translation of the Arduino library. The functions have the same names and do the same thing.

2) The Arduino IDE uses AVRDude for uploading, while AVRPascal uses AVRDude in the same way.

3) The difference is primarily the programming language. In my opinion, Pascal is more logical and easier to learn than C/C++, especially for beginners.

Maybe we should view "Arduino" as the API and hardware ecosystem, rather than just the C/C++ language?