Programming Arduino MCU and RP2040 on Custom Boards Using Arduino IDE - Page 1
Forum section: electronics / general

author: Sariel
author_rank: Regular Contributor
timestamp: September 26, 2024, 05:39:57 am
content: Hello,I primarily work as an analog/RF and board designer (so I tend to lurk on the other forums).Recently, I've started integrating simple embedded platforms to control my analog circuits or read sensors and close simple feedback loops. I’m comfortable using Arduino boards and the Arduino IDE for basic HAL programming, so no issues there.I’ve learned that there are libraries that allow the Arduino IDE to program Pico boards, which I haven’t tried yet but it looks straightforward.Now, I want to take things up a notch. I’d like to embed an Arduino-compatible MCU directly into my board (not just using a Nano or other board).I want to simplify the digital section and use the same MCU found on Arduino boards while doing my own layout.If I buy the same MCU used in Arduino boards and design my own layout, how do I program these MCUs using the Arduino IDE? What’s the official programmer for Arduino microcontrollers, and how do I install the bootloader for the first time? Do I need an FTDI programmer?I haven’t found much official documentation from Arduino, probably because they focus on selling the complete boards rather than the individual MCUs.As for the RP2040, I’ve seen good documentation from Raspberry Pi on hardware design around this MCU, but I’m struggling to find information on programming it and installing the bootloader for the first time.These devices arrive blank, right?How can I program an RP2040 using Picoprobe and the Arduino IDE if I design my own board around the RP2040?Thanks!

author: brucehoult
author_rank: Super Contributor
timestamp: September 26, 2024, 05:48:48 am
content: There is no such thing as an official Arduino programmer. You use exactly the same interface as you would to program the same hardware without going near Arduino.Generally the Arduino IDE uses avrdude software for AVRs and OpenOCD for many other chip types.MCUs are generally programmed using JTAG or SPI.Official Arduino boards (and some others) are programmed directly over USB and have an FTDI or other (e.g. WCH CH340) USB to uart/JTAG interface chip. For those that don't have an onboard USB converter like those you can use a cable with one built in. You can also run a special program on another Arduino or sometimes (e.g. for RP2040) another Raspberry Pi. For example the Arduino IDE has a specific board setup for "Arduino as ISP". You first download a special programmer "sketch" to one Arduino, then use that as the programmer for typically a bare AVR chip or an AVR chip on some custom board.

author: Sariel
author_rank: Regular Contributor
timestamp: September 26, 2024, 06:16:14 am
content: Thank you!Is there any good documentation on how to do this?If I want to use one of the microcontrollers from the Nano boards without the companion USB bridge controller, what’s the best approach? How should I program and upload sketches to the bare MCU? Should I use SWD, JTAG, or another method?Would a USB cable with a built-in FTDI adapter be sufficient?

author: brucehoult
author_rank: Super Contributor
timestamp: September 26, 2024, 06:23:53 am
content: Here's what I use for the ATTiny85. I haven't done a bare ATMega328, but I'm sure there are guides for that.https://www.instructables.com/How-to-Program-an-Attiny85-From-an-Arduino-Uno/I've programmed bare chips, and also chips built into a commercial product, using a SOIC-8 test clip.

author: DashApple
author_rank: Contributor
timestamp: September 26, 2024, 06:50:07 am
content: I'm just a hobbyist when it comes to microcontrollers but I've used the SMD package ATMega328 and DIP package type in most of my projects so can only speak about them, but it would apply to others in the family that have cores for the Arduino platform like the ATMega1284, ATMega2560 ectMy goto when using them is to upload the bootloader to the 328 so they can be programed over serial with a USB to uart bridge with the Arduino IDE, you could also go down the route of doing it with the SPI and no bootloader and using another Arduino as the ISP or some other dedicated programmer, I personally prefer the bootloader option as just requires the USB to uart bridge.Placing a connector that breaks out the serial port and SPI port of the MCu is a nice option if you switch or want to mess with either type of programming, I have done this on a few boards for testing, but keep in mind when you upload over the ISP the bootloader is overwritten so needs to be added back if you want uart capable programming againThe cable with the FTDI or such built in would be fine if you went down the bootloader with uart programming option, there are cheap boards around too with the USB to uart chip onJust my 2 cents

author: Lindley
author_rank: Regular Contributor
timestamp: September 26, 2024, 08:22:42 am
content: Installing a little CH340 chip onto your pcb would seem to make everything so much simpler than programming the AVR chip direct, plus if anyone else uses your board they can easiily reprogram it from their PC/Arduino ide with just a usb cable.

author: Sariel
author_rank: Regular Contributor
timestamp: September 26, 2024, 09:58:45 am
content: This sounds like a great idea. There are different versions of the CH430 chip.Which specific one should I use?Once the CH430 is on the board and the Windows drivers are installed, how do I program the bare AVR chip using the Arduino IDE before uploading a sketch?

author: Jeroen3
author_rank: Super Contributor
timestamp: September 26, 2024, 10:51:01 am
content: When embedding a mcu onto a board it's always wise to look if the chip in question has a rom bootloader.For example, the RP2040 has a USB bootloader, iirc it's a USB-MSC (your drop a bin file to it).Former ATmel parts (atmega/attiny) as used in Arduino do not have any, and you normally upload your firmware over USB-serial through a bootloader that was previously flashed into the chip before it was shipped to you.When you buy bare chips, this bootloader is missing. You have to flash this yourself, or find someone who can.I recommend to always obtain an original or compatible in-system-programmer.Because these often also have debuggin capabilities if the chip supports it.When I used AVR chips this used to be a AVR-ISP MKII, I see they have now replaced it for a more expensive ATMEL-ICE... Or maybe they made a pic/avr combo programmer?ST has the ST-Link, but many of their demo-board contain a miniature version of an st-link.You may also obtain a Segger, or other third-party ISP programmer, but these are often pricey.There will be many clones around of these tools if the chips are popular, ymmv.When using ISP you will need to make pins available on the board to a connector with a specific pinout.Read the datasheet of the chip and programmer to find out more.Many ST parts are also Arduino compatible, see the various Nucleo boards!

author: brucehoult
author_rank: Super Contributor
timestamp: September 26, 2024, 11:48:03 am
content: Quote from: Jeroen3 on September 26, 2024, 10:51:01 amThere are many places that sell them with bootloader already installed e.g. here are 10 chips for $33, pre-programmed:https://www.amazon.com/Atmel-Atmega328P-PU-Arduino-Loader-Installed/dp/B01KH54A6CQuoteI've reprogrammed AVRs in commercial products without such pins -- just attached a test clip directly to the chip.

author: drvtech
author_rank: Regular Contributor
timestamp: September 26, 2024, 02:44:47 pm
content: For AVRs I use a USBASP and connect it via a Tag-connect. No bootloader required (I use AVRDUDE) and the connector on the PCB costs absolutely nothing and takes up less space than a 6-way header. And you can put it on the back of the board if you're short of space on the top side.

author: Sariel
author_rank: Regular Contributor
timestamp: September 26, 2024, 04:29:44 pm
content: Thank you, everyone.Here's a summary of what I’ve gathered so far, with a focus on my preference to use the Arduino IDE for uploading sketches.(In the future, I plan to dive into more bare-metal coding, but not just yet.)I have the following options:1.Embed an Arduino Nano or Raspberry Pi Pico boards into my board layout. Both are compact enough, and I can directly use the Arduino IDE for programming. For the Raspberry Pi Pico, I'll need to download the necessary libraries and environment for the IDE (a topic to explore later).2.Embed the AVR devices used in Arduino boards directly. Connect them to a USB-to-UART bridge like the CH340.This raises a few questions:A. Which reputable companies manufacture CH340 devices, and are they available on Digikey/Mouser?B. Are these CH340 devices plug-and-play, or do they need programming? Would a Windows driver installation suffice?C. How do I use the Arduino IDE to install the bootloader?Once these steps are done, uploading Arduino sketches should be straightforward.3.Use RP2040 devices, which are great and outperform AVR devices. From what I understand, they come with a factory-installed bootloader, so I can upload sketches directly via USB, using the appropriate Arduino libraries,right?However, I’m unsure about the role of the Raspberry Pi Pico Probe. Do I still need it for programming, and is it compatible with the Arduino IDE?Raspberry provides good hardware guidelines for the RP2040 but lacks clarity on the various programming methods.

author: Lindley
author_rank: Regular Contributor
timestamp: September 26, 2024, 04:56:35 pm
content: Looking at several Arduino and ESP clone boards they all use the CH340G chip.Would assume the chps are ready to run, though you need to check the datasheets for the connections.Always assumed the CH340 is a Far East clone, so doubt you can buy " reputable " ones ?https://cdn.sparkfun.com/datasheets/Dev/Arduino/Other/CH340DS1.PDFAs said earlier you could add that chip and the few extra components it needs to your board, but it might be equally easier you use one of the very low cost CH340 modules and just put a 6 pin socket on your board ready to plug the module into at programming time ?Just depends if you want to regularly reprogam the AVR chips ?

author: westfw
author_rank: Super Contributor
timestamp: September 26, 2024, 09:06:37 pm
content: QuoteDo what? There has to be more documentation on Arduino and Arduino-like boards out on the www than nearly any other subject. Starting with the complete published schematics, board layouts, and source code for the Original Arduino(s) plus half a dozen credible derivative works. How are you not finding it?QuoteThey're manufactured by WCH Qinheng Microelectronics in China, and AFAIK you currently have to buy them from China via dealers like Aliexpress.Seehttps://wchofficialstore.aliexpress.com/store/1102052740/pages/all-items.html?shop_sortType=bestmatch_sortThey're not "programmable" per se, but do need a windows driver installation.I'm more fond of the pre-built "modules" (also available from China, or from some Amazon dealers.)https://www.aliexpress.us/item/3256806016175910.html- about $1 gets you a pre-wired WCH chips with (your choice of) USB connector, Power and Traffic LEDs, and a common pinout for connection on your board.)Ends up looking like this:

author: drvtech
author_rank: Regular Contributor
timestamp: September 26, 2024, 11:26:42 pm
content: With my method (post #9) you can still program directly from the Arduino IDE. Go to Tools|Programmer and choose USBasp (only need to this once) then go to Sketch|Upload using programmer. That's it. You'll need a USBasp board (less than a fiver on eBay) and if you don't want to go to the vast expense of a 15 quid TAG-Connect lead you can put a bog-standard 6-pin header on the board and use the lead that comes with the USBasp. Most Arduino boards have one of these headers which you use for burning bootloaders, (which I think answers one of your other questions).

author: Sariel
author_rank: Regular Contributor
timestamp: September 27, 2024, 09:21:30 am
content: Quote from: Lindley on September 26, 2024, 04:56:35 pmI like the idea of using an external CH430 programmer.If I add a bare AVR MCU (like the ones used in Arduino) to my board, how can I upload the bootloader for the first time?After that, I understand uploading sketches with the CH430 should be straightforward.Thanks!

author: Sariel
author_rank: Regular Contributor
timestamp: September 27, 2024, 09:26:53 am
content: If I design a layout with the RP2040:1. Do RP2040 devices come blank, or do they include a bootloader?2. On my custom-designed board with the RP2040, will I need an external programmer, or can I simply use the USB connection to upload the program?3. What is the recommended method for programming the RP2040 using Arduino? I've heard about Earle Philhower's framework—does it work well, and will it be compatible with my custom RP2040 layout?Thanks!

author: Lindley
author_rank: Regular Contributor
timestamp: September 27, 2024, 10:20:41 am
content: Quote from: Sariel on September 27, 2024, 09:21:30 amIf you seach Ytube on "bootloader to atmega328" you will find lots of examples of how to do that.What you need to appreciate is that its not just the microchip that you put on your board, they do need extra components like Crystals and Caps to make them run.Although we have not used them, the RPi 2040 chips need quiet a lot of components to make it run - see this pdf.https://datasheets.raspberrypi.com/rp2040/hardware-design-with-rp2040.pdfPerhaps you can now see that for both the AVR and RPi chips, using the lo-cost ready made plug in modules is probably a much simpler and better solution, though agree, possibly not as integrated looking as a chip on the pcb.Also wonder what features you are looking with the RPi chips vs the AVRs, wifi, BT, extra speed ? You might want to look at the ESP32 modules , they are coded and programmable from the Ardunio IDE.Lots of ESP info here -https://randomnerdtutorials.com/

author: Sariel
author_rank: Regular Contributor
timestamp: September 27, 2024, 12:05:23 pm
content: Quote from: Lindley on September 27, 2024, 10:20:41 amThank you!I'm an experienced board designer with a strong background in analog, RF, and power systems, though I have limited experience with embedded development. I’m confident I can design the circuitry around the MCU and reverse engineer Arduino/Pi boards.My main concern is the programming and bootloading process, as I want to avoid ending up with a bricked board.Another question just came to mind:If I create my own layout using AVR devices but assign different pins than Arduino, will Arduino sketches still work? For example, will the "blink" sketch function properly?Since Arduino HAL libraries refer to the pin numbers based on the board’s pinout rather than the MCU’s actual pins, this could cause a mismatch, right?

author: Lindley
author_rank: Regular Contributor
timestamp: September 27, 2024, 02:01:08 pm
content: Quote from: Sariel on September 27, 2024, 12:05:23 pmBasically yes, But most micros i/o pins are multi-functional . such as digital only, Analogue, PWM etc. so you have to check the datasheet etc to ensure the pin you want to use has the function your need.These diagrams give you an easy quick reference but always check with the datasheet if unsure.https://content.arduino.cc/assets/Pinout-NANO_latest.pdf

author: Sariel
author_rank: Regular Contributor
timestamp: September 28, 2024, 01:58:38 pm
content: I came across this link in the Arduino documentation that explains how to use the in-circuit programming (SPI) interface by turning another Arduino board into a bootloader programmer.https://docs.arduino.cc/built-in-examples/arduino-isp/ArduinoISP/?_gl=1*5eu64j*_gcl_au*NTU0MTU1OTAyLjE3MjU2MDkyMzM.*FPAU*NTU0MTU1OTAyLjE3MjU2MDkyMzM.*_ga*MTQwODcyMDU2NS4xNzI1NjA5MjI5*_ga_NEXN8H46L5*MTcyNzQzOTc3MS4xNC4xLjE3Mjc0Mzk4NTYuMC4wLjEwNTI1NDk4OTU.*_fplc*Smhob2R4cFRxNDRlRmdUQ3dBQ3JENTh5ZTlQYndaNjhQYUpwZUJkNFpGRXBHcWhJa2ZDcVlyRHQ2WFRWeUQzcSUyQjFiYkZtTjVwMHBkZE85eTFQVThYUFVoJTJGdXRjYSUyQmJKUzdSaXlia0pHZFpETzZJZmNmSkVYQ0JQVmR6SFZ3JTNEJTNENow, let’s say I design my own PCB using an AVR chip like those found in Arduino devices and mount a bare MCU on my board.If I burn the bootloader using that method, what’s the next step?Do I just use the CH430 and upload sketches through the UART interface it provides, or is there more to the process?After the bootloader is loaded to a bare AVR chip, what is the simplest method to upload the sketches?

author: brucehoult
author_rank: Super Contributor
timestamp: September 28, 2024, 03:01:11 pm
content: Quote from: Sariel on September 28, 2024, 01:58:38 pmI already sent you a link to information how to do that three days ago.https://www.eevblog.com/forum/microcontrollers/programming-arduino-mcu-and-rp2040-on-custom-boards-using-arduino-ide/msg5655369/#msg5655369

author: tooki
author_rank: Super Contributor
timestamp: September 28, 2024, 03:37:47 pm
content: Quote from: Sariel on September 26, 2024, 09:58:45 amTo flash the bootloader to an AVR, you need to use SPI. So why even bother with the bootloader, only to then need another piece of hardware to upload the sketch? You can flash your sketch to the AVR directly, with no bootloader. This saves you a big programming step, and is faster to flash, and the MCU boots faster. Yes, you can do this with Arduino IDE.Not that I would likely design a new product around an AVR, since they're not particularly powerful for what they cost.If you do decide to use a bootloader and USB-serial bridge, instead of the CH340 or other no-name Chinese chip, I'd use an FT232 or CP2102N. The FTDI chips are the best supported out of the box on a wide array of OSes.The RP2040 has USB built in.

author: tooki
author_rank: Super Contributor
timestamp: September 28, 2024, 03:55:46 pm
content: Quote from: Jeroen3 on September 26, 2024, 10:51:01 amThey combined them. The PICkit 4 and 5 are now the low-cost programmer/debuggers for the AVR chips. I thought they were not supported in AVRdude (and thus in ArduinoIDE), but apparently the PICkit 4 will respond as an AtmelICE if addressed as one, so AVRdude supposedly just works with it. The PICkit 5 (and MPLAB ICE 4 and MPLAB ICD 5), on the other hand, are not supported by AVRdude.But given that a $3 Arduino Uno clone can be flashed into a programmer, or that you can get a USBasp or AVRasp clone from aliexpress for $3, I wouldn't bother with the original tool, at least not for simple flashing. It'd definitely be worth it for debugging in MPLAB X.

author: Lindley
author_rank: Regular Contributor
timestamp: September 28, 2024, 04:06:35 pm
content: This tutorial might be more helpful for you than Bruces good one, as it shows the connections for programming the Arduino 328 chip.https://www.instructables.com/How-to-Burn-the-Arduino-BootLoader-on-to-a-AtMega3/Once you have programmed the bootloader you can program your user program from the Arduino IDE using either the same method as the bootloader, or using one of the USB CH340 modules or one of those Tooki mentions which connect to the 328s Serial instead of the SPI pins.Tip, if using a Crystal on a breadboard as in the tutorial above, its leads are very thin and often create a poor connection and the programming can fail, best to solder some thicker, but short wires to its lead so you have a sound connection.

author: Sariel
author_rank: Regular Contributor
timestamp: September 28, 2024, 06:36:02 pm
content: Thank you all for your input.Here’s a summary:It’s possible to burn the bootloader onto an AVR using the SPI pins with another Arduino acting as the programmer and the Arduino IDE. Once the AVR has the bootloader, it can be programmed using external USB cables or onboard chips like the CH430/FTDI or still through the SPI pins. (But what will happen if other devices are on board and connected also to these SPI pins. Will they be damaged during programming??)The reason I'm pursuing this is that, although I prefer using the Arduino IDE (I'm still fairly new to programming), I can't rely on Arduino boards being around long-term, as they are frequently updated or become obsolete. The AVR chips, on the other hand, are likely to outlast them, so I'm considering directly integrating the AVRs into my designs.I agree that performance-wise, these devices aren't the best. That's why I'm also researching RP2040 devices and, eventually, the RP2350. I still need to figure out their bootloading and programming processes as bare chips, but that might be a topic for another discussion.

author: Lindley
author_rank: Regular Contributor
timestamp: September 28, 2024, 08:26:43 pm
content: Yes, your summary is ok, but you would need some isolation procedure if wanting to use the SPI pins for programming and the user circuit.Using the typical Serial Pins ( as do the Arduino boards and Serial Monitor) would seem a better way to upload the user program.The AVR chips have been in use for so many years and will doubltess be around for some time, but everything changes with time.Would suggest you get hold of an Arduino Uno or similar and gain practical expereince of it and the Arduino IDE before even considering things like the RP controllers.

author: tooki
author_rank: Super Contributor
timestamp: September 28, 2024, 10:59:28 pm
content: Quote from: Sariel on September 28, 2024, 06:36:02 pm(Since you keep repeating the error over and over: it's CH340, not CH430.)I think you missed my point: if you program via the SPI pins, youdo notneed a bootloader. The bootloader's job is to add serial programming. If you use SPI programming, you skip the bootloader altogether. In fact, if you use SPI programming, you will overwrite (=delete) the bootloader if you had flashed it before.Consider:-Using AVR with bootloader:Step 1. Connect SPI programmer.Step 2. Flash bootloader.Step 3. Disconnect SPI programmer.Step 4. Connect serial adapter (if no USB bridge built in) or USB cable (if USB bridge built in)Step 5. Upload sketch via serial.Step 6. Disconnect serial adapter or USB cable.-Using AVR without bootloader:Step 1. Connect SPI programmer.Step 2. Flash the sketch.Step 3. Disconnect SPI programmer.The sole advantage of using the bootloader is if you want your users to be able to upload new firmware without needing an SPI programmer. Other than that there are no advantages at all.Quote from: Sariel on September 28, 2024, 06:36:02 pmDepends on your circuit design. Ideally, you'll either leave them free, or share them with things where it does not matter. Otherwise, you can program the MCUsbeforeinstalling them in the board, and/or use some 0 ohm jumpers to make it possible to isolate the rest of the circuit if need be.If you use SPI programming, you can completely free up the IO0 and IO1 pins, which are normally used up for serial programming -- as long as you don't need that serial for communication with the running MCU, of course!Quote from: Sariel on September 28, 2024, 06:36:02 pmLOLwhat?!?!Arduino keeps most board models around forever! The Arduino Uno has been around since 2010 and is still sold today. (The Uno R3 revision with 328p chip, the most popular Arduino board, has been sold since at least 2013, and is still sold today.) They keep adding new models, but haven't retired all that many. And even when they do, it's no big deal. One of the biggest strengths of the Arduino platform is portability between not just boards, but entire architectures. I can write the same code and run it nearly or entirely unchanged on an Arduino Uno, an ESP32, a Teensy, a Rpi Pico, or STM32 Nucleo board. (All you really need to change is the pin numbers.) The onlymajorMCU architecture that is categorically unsupported on Arduino is PIC -- and there has been some work towards this, but never quite to completion.In fact, I often do this when first developing algorithms for a sketch: write and debug on an Uno, then use it on an ESP32. (Compiling for ESP32 takes way longer than compiling for AVR, so it's faster to develop on AVR.) If possible, I do SPI programming since it uploads even faster.Where things get hairier is if you start using hardware features specific to the MCU in question. You can sometimes use libraries that abstract this away in a way that is hardware-agnostic (or that actually uses each MCU's hardware features to do it). For example, the TaskmanagerIO library lets you schedule things, and under the hood it will use the timers of the MCU you're using, or of the underlying FreeRTOS on the ESP32 or Rpi Pico. With the Uno being fairly basic, moving up to a bigger MCU is rarely a problem.In the end, chances areyouwillwantto migrate away from AVR sooner than any other factor would force you to.Quote from: Sariel on September 28, 2024, 06:36:02 pmArduino is open source, so as long as Microchip keeps making the chips, clone makers will keep making Arduino boards if there's demand for them, regardless of what Arduino itself decides to do. You can also do it yourself quite easily. But there is absolutely no reason to assume Arduino itself will stop, and as I said, even if they did, it doesn't matter.I assume we are talking about hobby projects here. I would not integrate Arduino boards into a commercial product. You'd integrate a modern MCU directly.Quote from: Sariel on September 28, 2024, 06:36:02 pmIt's fundamentally the same as a Rpi Pico. The bootloader is factory-programmed in ROM. See e.g.https://raspberrypi.stackexchange.com/questions/145812/how-to-program-a-rp2040-chip-i-dont-have-a-pico-board-just-the-chip-im-buiYou must provide the Flash memory chip, then the factory bootloader lets you program it.

author: dobsonr741
author_rank: Frequent Contributor
timestamp: September 29, 2024, 04:37:35 am
content: QuoteThe RP2040 has the bootloader in ROM, as it comes from the factory. Simple as that. Just plug into USB, hold BOOTSEL down, reset.If interested in the bootloader source, here it is:https://github.com/raspberrypi/pico-bootrom-rp2040More on the boot process:https://vanhunteradams.com/Pico/Bootloader/Boot_sequence.html#Hardware-controlled-boot-sequence

author: brucehoult
author_rank: Super Contributor
timestamp: September 29, 2024, 05:13:41 am
content: Quote from: tooki on September 28, 2024, 03:37:47 pmWCH are not a "no name" Chinese company. They have been around for a long time, and large numbers of manufacturers have switched from FTDI to CH340 for price, features, and non-being-bastards reasons.SparkFun, for example, uses the CH340 on a lot of products now, and have driver install instructions here...https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/allMaybe not OOTB (yet), but not exactly hard.

author: westfw
author_rank: Super Contributor
timestamp: September 29, 2024, 09:55:14 am
content: QuoteAlso, They’ve done an impressive job of providing documentation and support for “western” users.(And particularly low volume and hobbyist users.)Between WCH, Espressif, and Seeed, the whole landscape has shifted, wrt using “Chinese technology”Hopefully it won’t be destroyed by the next US administration.

author: tooki
author_rank: Super Contributor
timestamp: September 29, 2024, 10:25:07 am
content: Quote from: brucehoult on September 29, 2024, 05:13:41 amMy wording was suboptimal; I intended it as CH340 + (no-name Chinese chips), not as WCH being no-name.However, my advice to not use it stands, insofar as FTDI and SiLabs are much better known, and meet OP’s request of being available from DigiKey and Mouser.

author: brucehoult
author_rank: Super Contributor
timestamp: September 29, 2024, 11:40:12 am
content: Quote from: westfw on September 29, 2024, 09:55:14 amYeah, Seeed have been around for a while now. I think the below were my first two orders from them, in May and June 2013. Some 433 MHz transmitters (which I used to control Jaycar remote control 240V sockets from an Arduino), then nRF2401 for things that needed 2-way or at least ACK'd communication. Those things were like $3 each at a time when Zigbee, WIFI, BT cost a fortune.The nRF2401 were basically a UDP-like thing with limited size (32 byte) packets, but you could build whatever protocol you wanted on top of them. The code size to drive them was trivial. Soon after I got them I demonstrated at a conference using one attached to a Freetronics LeoStick (ATmega32U4) stuck in a USB port on my MacBook Pro, communicating across a room to a battery powered Pro Mini with a couple of 5g RC servos attached. I whipped up a quick and dirty Mac app using Interface Builder (ObjC) that let me wiggle sliders on the Mac screen and the RC servos moved in sync with them.

author: Sariel
author_rank: Regular Contributor
timestamp: September 29, 2024, 11:49:10 am
content: Thank you all for the additional insights.To summarize:There are two main options for programming standalone bare AVR devices:1. SPI Programming via Arduino (or compatible programmer): Using the ISP method, you can burn the bootloader. Once the bootloader is in place, you can program the device using the serial communication method (e.g., USB to UART) via an FTDI-USB cable or onboard chip.2. Direct Programming via SPI Pins: This option skips the bootloader entirely, allowing you to directly program the device through the SPI pins.Since I'd like to allow other users to reprogram my board easily, I'll stick with the USB-UART method, meaning I'll need to burn the bootloader.I also need to ensure that any other devices connected to the SPI lines are disconnected during programming.This can be done using a 2x3 pin header connector (0.1” pitch) with jumpers or by using jumper resistors.When using ISP programming, the CS pin isn't used, correct?Regarding the RP2040, since it comes with a built-in ROM bootloader, I can simply hold the reset button while powering and connecting via USB, allowing me to upload the program file through drag-and-drop. But how do I upload code through the Arduino IDE? If I stick to the Arduino HAL while still working with the RP2040?Lastly, I need onboard Flash for storing programs. Isn't the RP2040’s internal Flash sufficient for simple programs?And how difficult is the transition from Arduino IDE with AVR to RP MCUs? Is it just a slight increase in complexity (a few dB) or more like a 30-40dB jump?

author: tooki
author_rank: Super Contributor
timestamp: September 29, 2024, 01:30:00 pm
content: Quote from: Sariel on September 29, 2024, 11:49:10 amSeehttps://ww1.microchip.com/downloads/en/Appnotes/Atmel-0943-In-System-Programming_ApplicationNote_AVR910.pdfQuote from: Sariel on September 29, 2024, 11:49:10 amhttps://letmegooglethat.com/?q=rpi+pico+how+to+upload+from+arduino+ideQuote from: Sariel on September 29, 2024, 11:49:10 amWhatinternal Flash? It doesn't have any! The last digit in "RP2040" (the ones column) refers to the amount of built-in nonvolatile memory:RP2040= 0kB.Rpi has plenty of information on building your own RP2040 boards, including the design files for the Rpi Pico series, a KiCad project for the minimum viable system, and a "Hardware Design with RP2040" design guide. All onhttps://www.raspberrypi.com/documentation/microcontrollers/silicon.html#rp2040See e.g.https://datasheets.raspberrypi.com/rp2040/hardware-design-with-rp2040.pdfpage 8Quote from: Sariel on September 29, 2024, 11:49:10 amAs I said above: for simple sketches, there is zero additional complexity, other than initial configuration of the IDE to add board support. I thought I made it abundantly clear that one of the Arduino platform's biggest strengths is the ease of moving from architecture to architecture.

author: tooki
author_rank: Super Contributor
timestamp: September 29, 2024, 01:48:43 pm
content: P.S.Quote from: Sariel on September 29, 2024, 11:49:10 amFYI, on both ESP32 and Rpi Pico with Wifi, you can do OTA (over-the-air) updates. I haven't done it on Rpi Pico yet, but on ESP32 it's ridiculously easy to set up. Huge advantage to this is closed-box firmware updates, and no chance that your USB-serial bridge chip will require driver installation, which some users may be unable to do.

author: Sariel
author_rank: Regular Contributor
timestamp: September 29, 2024, 02:51:13 pm
content: Is there also a need to change the pin numbers in the code, sometimes when moving from one architecture to another?

author: tooki
author_rank: Super Contributor
timestamp: September 29, 2024, 03:02:45 pm
content: Quote from: Sariel on September 29, 2024, 02:51:13 pmI already explained this yesterday.Quote from: tooki on September 28, 2024, 10:59:28 pm

author: Lindley
author_rank: Regular Contributor
timestamp: October 01, 2024, 05:12:58 pm
content: Hey @Sariel, wondered which direction you had decided on , the AVR or Pico route with the Ardunio IDE ?Your interest in the Pico and Pico2 (RP2350) made us have a closer look at the latter and just received a basic board which has loaded a test program ok, but as you can see from this forum thread about the Pico2 it has a lot points to consider so probably worthwhile you starting off with the AVR, though as we do not know in any detail what you are expecting such a chip to do on your boards is hard to be sure if either will do what you want.https://www.eevblog.com/forum/microcontrollers/possible-click-bait-title-the-raspberry-pi-pico-2-now-has-extra-risc-v-cores/

author: Sariel
author_rank: Regular Contributor
timestamp: October 01, 2024, 07:57:31 pm
content: Quote from: Lindley on October 01, 2024, 05:12:58 pmAfter reviewing all the responses and consolidating the information, I've developed a structured work and learning plan for myself.I'll begin by focusing on AVR devices, working initially with Arduino modules. I plan to establish communication with some of the devices I commonly use and test code transfer between different modules. Once I get comfortable with this, I'll design my own AVR board or a stamp-sized version and integrate it into my circuits.Next, I'll move on to the RP2040 (PICO board) and then aftwerward experiment with direct integration.I noticed that the Pico board has a lot of unused area, making it less efficient for my needs.I have a strong feeling that the RP2040 will remain relevant for a few more years, making it a solid choice for integration, even in some of my more advanced modules. I don't thing these MCU will have any longevity problems.Since I primarily use MCUs for control and monitoring rather than data processing, these devices should be more than adequate.Once I gain more confidence, I'll move on to STM32 devices and start using the Cube HAL library for more complex projects.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 01, 2024, 08:24:56 pm
content: Quote from: brucehoult on September 29, 2024, 11:40:12 amThe later revision was the nRF24L01+ with some improvements. It's now obsoleted, which is a shame. It was very easy to use, drew minimal power and allowed you to implement custom protocols in a much easier way than what you can do these days with their MCU-based RF chips, which require firmware inside the chip with a much steeper learning curve (unless you just use ready-to-use examples with one of the standard protocols).I still have a bunch of nRF24L01+. You can more or less find "equivalents" (although more expensive, but also with deeper FIFOs and more features) from Semtech now, both for the 2.4GHz band and for the sub-GHz bands.