Author Topic: Transitioning from Arduino IDE 2 to Microchip Studio  (Read 6502 times)

0 Members and 1 Guest are viewing this topic.

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12602
  • Country: ch
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #25 on: April 27, 2023, 09:42:25 am »
Here's a tip, just forget about the arduino, you are either using it and it's lets say specific way of doing things or you are letting yourself loose on a microcontroller and now have full control over it and are not tied to the particular one the arduino happens to use.
This shows that you know very, very little about Arduino, and should probably refrain from commenting on it so vociferously until you learn more about it.

1. You have nearly full control over Arduino hardware. You can write directly to registers. Pretty much the only thing you can’t change much is the programming fuses. Not an issue in most situations. (And you can do it if you’re really intent on it.)

2. You can choose to use Arduino library functions or not. You most certainly are not required to use them.

3. The Arduino framework is supported on a wide array of hardware, not just “the particular one Arduino happens to use” (which is also wrong, since even Arduino-branded boards use a variety of architectures). You’re not “tied to” their hardware. Quite the opposite, I consider code portability to be one of the biggest advantages of the Arduino ecosystem: I can write code that will run unmodified on AVR, ESP32 (both Extensa or RISC-V models), SAMD, STM32, and others. That is not the case when using the manufacturers’ dev environments, where you’re more closely tied to their specific HAL syntax.

Edit: fixed typo
« Last Edit: April 28, 2023, 11:31:30 am by tooki »
 
The following users thanked this post: uliano

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18034
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #26 on: April 27, 2023, 08:58:40 pm »
So what you are saying is that Arduino has morphed into a bunch of cross platform standard libraries. Given my experience with Arduino itself which yes, yes it's perfect, so perfect that it's only on here that I get nuggets of information on how profoundly nuts some of what is under it's skin is that I would never trust anything with the arduino brand. STM32? look, just get up to date and have chatGPT write your code :)
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15337
  • Country: fr
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #27 on: April 28, 2023, 01:07:00 am »
As formulating clear specifications is often the hard part, can we use ChatGPT to have it generate a well-structured query for ChatGPT to generate your code?
 
The following users thanked this post: tooki, uliano

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4310
  • Country: us
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #28 on: April 28, 2023, 03:00:18 am »
Quote
how profoundly nuts some of what is under [Arduino's] skin
Such as?
The usual complaint is things like digitalWrite(), which is some 50x slower (on AVR) than the single instruction that sort-of does the same thing, as long as you have completely different assumptions and requires for the arguments.

I could write a paper on things that I think Arduino had done wrong, but very little of it approaches "profoundly nuts" (and the biggest mistakes, IMO, are in trying to maintain backward compatibility in newer code for things that were idiosyncrasies of the original AVR (like "these board-level pins will have PWM capability", or "digitalWrite a 1 to a pin in INPUT mode turns on the internal pullup."  Sigh.)
 
The following users thanked this post: tooki, uliano

Offline uliano

  • Regular Contributor
  • *
  • Posts: 178
  • Country: it
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #29 on: April 28, 2023, 05:36:05 am »
Quote
how profoundly nuts some of what is under [Arduino's] skin
Such as?
the biggest mistakes, IMO, are in trying to maintain backward compatibility in newer code for things that were idiosyncrasies of the original AVR (like "these board-level pins will have PWM capability", or "digitalWrite a 1 to a pin in INPUT mode turns on the internal pullup."  Sigh.
This stuff is also well known and avoidable, on the other hand there are parts of Arduino that are way better than any HAL or any 10 lines self made code. E.g. I read recently the implementation of uarts in dxCore and I couldn’t come even close to that. The approach to Arduino could/should be to keep the good and go bare metal for the rest.
« Last Edit: April 28, 2023, 07:31:36 am by uliano »
 
The following users thanked this post: tooki

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12602
  • Country: ch
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #30 on: April 28, 2023, 11:41:37 am »
So what you are saying is that Arduino has morphed into a bunch of cross platform standard libraries.
In a sense, yes. Though that’s nothing new. I didn’t touch Arduino until 2014 or 2015 and by then it was already on numerous platforms.

Given my experience with Arduino itself which yes, yes it's perfect, so perfect that it's only on here that I get nuggets of information on how profoundly nuts some of what is under it's skin is that I would never trust anything with the arduino brand.
Can you rewrite that run-on sentence into comprehensible English? The only part that’s clear is “I would never trust anything with the Arduino brand”.

STM32?
What about it?


Look man, it’s fine to have legitimate complaints about something. But the hate against Arduino is often not grounded in reality. Or it’s based on issues that were resolved ages ago. Either way, I think it does people a big disservice to dissuade them from using it on principle, as opposed to using current, factual reasons to let people weigh which approach might be best for their use case. If I were writing the firmware for a car engine ECU, Arduino would be decidedly wrong, and a safety-certified toolchain from the MCU manufacturer would be appropriate, even if it had a steep learning curve. Conversely, if a novice wants to learn system integration by combining inputs and outputs, various peripherals, etc, and general code writing, but without having to delve into the registers of every external peripheral they want to use, Arduino is ideal. Then, as they run into the limitations of the Arduino IDE, they’ll move to a better one. And as they learn how to improve libraries, they will. And then they’ll write their own.
 
The following users thanked this post: uliano

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12602
  • Country: ch
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #31 on: April 28, 2023, 11:44:59 am »
My trajectory started with Atmel Studio, then I adopted VSCode for many other stuff and become addicted to IntelliSense so I switched to Platformio that, for avrxxxDx, allows you to create only "Arduino framework" projects. The fact that the framework is there doesn't force you to use its API, in fact I only use millis() and Serial, the rest of the code accesses peripheral registers directly.

On occasion I feel the lack of the debugger and I would have liked to be able to convert the project for Microchip Studio or MPLABX IDE. Alas, I can't.
What about the debugger in PlatformIO? I’ve used it a fair bit (on ESP32 hardware).
 

Offline uliano

  • Regular Contributor
  • *
  • Posts: 178
  • Country: it
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #32 on: April 28, 2023, 02:20:38 pm »
On occasion I feel the lack of the debugger and I would have liked to be able to convert the project for Microchip Studio or MPLABX IDE. Alas, I can't.
What about the debugger in PlatformIO? I’ve used it a fair bit (on ESP32 hardware).

Enjoyed it with ESP32 and STM32, not available for AVRxxxDx and ATmega480x, the AVR chips I use.

For some, older, AVRs there is avr-stub
« Last Edit: April 28, 2023, 02:24:23 pm by uliano »
 
The following users thanked this post: tooki

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18034
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #33 on: April 28, 2023, 03:53:02 pm »
I've been told that there is a weird thing with millis() where if you take two time stamps they may actually be back to front due to how it fudges it.

I have struggled to do just normal code as if you code goes too deep like more than a couple of levels of if's it fails. Essentially my main issue is that if you have a problem it is hard to sort out and it's therefore not worth it especially when there ids little support other than a bunch of clueless people telling you how perfect it is. I can create pretty much the same functions like pinRead() etc very quickly on any MCU, I generally use the micro controller as a micro controller, the only reason I would use the arduino is so that I don't have to access the hardware at a low level but then the functionality you get is a fractional amount of the peripheral capabilities and I tend to be doing proper electronics not just using it as a PC so need to play with those peripherals. So sure I can do that in Arduino, but then what is the point of the arduino system if I am fiddling with the low level stuff.

The panacea of just jumping from one micro to another very different one without having to change the code just does not exist unless you are severely underusing the thing.

I mean tell me, with a SAMD based board does the ADC average samples? I use the SAMC, not sure if an Arduino layer for it has been written but one of the reasons I could get some what that it was not on an arduino board.... with a few lines of code the ADC is set up and runs a round robbin giving me 16 bit oversampled readings that are very filtered with a channel read each 1ms.

It's not that I just dislike the arduino, what I dislike is the happy clappy lets just throw some shit together and feel proud of the thing we made while not really knowing how it works because we just downloaded some code that we have no idea what it does.

If all you want to do is flip some pins, sure.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15337
  • Country: fr
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #34 on: April 28, 2023, 06:22:50 pm »
The panacea of just jumping from one micro to another very different one without having to change the code just does not exist unless you are severely underusing the thing.

Once you start doing anything non-trivial, that's basically right.

The same thing holds for cross-platform apps, like Java was thought to solve all of this and more (maybe the world hunger, if Java was popular right now, it would be saving the climate). But in practice, you still end up having to write platform-specific code in some ways and getting bugs that are specific to a given platform.

With that said, you can write a sizable chunk of your code in a portable way and "isolate" the target-specific code as much as it makes sense. This is what I strive to do. This way you can reuse most of your code, but you *don't* expect not to need any porting work.

Solutions like Arduino tend to hide this fact to the programmer and thus tend to make them assume there will be no work involved when switching targets.

Portable code is great (unless you are making money off the number of LOCs you write), but aiming for the lowest common denominator is less so. It will get you just that.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18034
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Transitioning from Arduino IDE 2 to Microchip Studio
« Reply #35 on: April 29, 2023, 08:46:43 am »
Are you talking about Java as in PC's?

From what I see many people coding micro these days are more computer programmers than electronics engineers. Stop anyone in the street and ask them what they think electronics is and they will basically start talking about computers. Dave did a drive time rant on this many years ago where he said that he ends up not challenging people who make the assumption he designs computers because it's just too much effort to explain.

When we talk about PC's we assume an x86 standard platform, so if you have an OS you love chances are it will work on any x86 or derivative, this is a given to the point that many probably do not understand the level of standardization. Companies who might be at each others throats in advertising are actually working together in the background to make sure that their products are compatible so that they can both be picked for your OS of choice.

Then we come to operating systems. Now I am well aware that there are many programs that work on multiple operating systems. So clearly whatever high level language they use, this is supported on any OS used and the same code will produce the same result, because obviously the whole world does not do the same work 2 or 3 times over just to get the same results. There will of course be a massive amount of work done by someone else to ensure the same resources are available in each OS and that they appear the same so that the code can simply be recompiled.

But everything I have outlined above has one thing in common, the hardware!!!!! a motherboard from asus will function just as well as one from msi because they both use components that adhere to a standard. Micro controllers are hardware, and they are not standard!!! The closest we have to standardization is that we all use C and C++ and well there are others of course. I learnt C not because I felt it was what I needed but because everyone else uses it and if I wanted help asking for help in some obscure implementation of basic would probably not get me anywhere. the peripherals are different on any MCU, even MCU's of the same brand will have wildly different procedures for setting them up and features.

I use the SAMC, it has 2 types of counter on the one chip! I can't even write standard code that will work on both types of counters on the same chip!!!. Well I could, but I would have to strip the functionality of the more complicated one down to that of the simpler one. Where do I stop? a TC has 2 PWM outputs, a TCC has 4 PWM outputs and can have a second set of 4 PWM outputs that are delayed relative to the main 4 so that you can do dead times for things like push-pull outputs.

So do I write my standard code so that any counter is treated the same? well if I did that I would reduce a TCC down to about 1/4 of it's functionality just for something that is one of the functions the counters can do. In my current project I am actually running out of counters. If I did this I would actually have run out and have to get a bigger chip. So instead of the SAMC21J with 64 pins I would get a SAMC21N with 100 pins, oh but on this chip although you have more counters these extra ones share the interrupts of the already existing ones, this now complicates the code and actually slightly slows things down potentially, not to mention the cost.

What I am saying is that there is no free lunch. A micro controller that is not running an operating system but being used as a real time device is an electronic component, it is an ASIC without the need to pay the cost of actually getting an ASIC made, why are we trying to use them as computers and expect the same panacea of compatibility from sub 1$ devices that we have from at the least, a $50 SBC which can still be a bit of an ask or a PC that costs several hundred dollars?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf