Thoughts on the RP2040? - Page 1
Forum section: electronics / projects

author: tomgat
author_rank: Regular Contributor
timestamp: October 21, 2022, 07:24:19 pm
content: I was looking at the Raspberry PI Direct website and noticed they are selling their RP2040 (aka Raspberry Pico chip) for $400 for a reel of 500 (ie. $0.80 each) a piece. Also, since this processor needs flash, they are also selling 16Mbit QSPI-capable serial NOR Flash for $1000 for a reel of 4000 (ie. $0.25). The chip has an oscillator onboard (no very accurate, but still) as well as an RTC. Please someone correct me if I wrong, but this seems like a very good price for a ARM M0 dual core processor with great documentation and an easy to place QFN package. Any idea why we are not seeing more people design with this processor?Any thoughts are appreciated, as I am looking for a low cost processor to design with that is not back ordered until 2023 (and beyond).

author: uer166
author_rank: Super Contributor
timestamp: October 21, 2022, 07:46:01 pm
content: Quote from: tomgat on October 21, 2022, 07:24:19 pmFrom the place/requirements where I work, and why STM32 is still the best fit, RP2040, while interesting, is a no-go for a lot of reasons:No security of any kind since code is stored externally without encryption.Lack of good peripherals, especially in mixed signal/analog domainLack of industrial communication interfaces such as CANLack of basic communication peripherals as well (only 2 HW UARTS, although I'm sure PIO can fill in some gaps)Temp range insufficient for some workOnly one chip in family without any options to increase memory/GPIO/different package. Horses for courses and only having one option is a huge risk for any big project.It may be a good fit for some consumer hardware, however.

author: tomgat
author_rank: Regular Contributor
timestamp: October 21, 2022, 07:51:40 pm
content: Quote from: uer166 on October 21, 2022, 07:46:01 pmYou make great points that the chip is pretty limiting, but its also a fraction of the cost to STM32. Also, I am struggling to get allot of the STM32 chips right now.I was looking at the temp range specs as I do exclusively industrial designing. Thats appears to be the typical industrial range.Operating temperature -40°C to +85°Chttps://www.raspberrypi.com/products/rp2040/specifications/

author: Monkeh
author_rank: Super Contributor
timestamp: October 21, 2022, 08:01:18 pm
content: Quote from: tomgat on October 21, 2022, 07:51:40 pmIt is, but you also need to factor in the cost of external flash and other external peripherals due to its limited feature set. Don't forget board space is also a cost.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 21, 2022, 08:11:15 pm
content: One of the reasons I'm seeing more commercial projects these days with the RP2040 is precisely due to its availability, so you're not alone.Apart from what uer166 said, minus points are also that it has unimpressive power consumption for a Cortex-M0+ compared to the competition. In particular, it has no decent "deep sleep" mode, so power consumption is going to be a problem for many battery-operated applications. I think the lowest that has been measured in deep sleep was about 300 µA - and even that was achieved with great care. The competition routinely achieves 100x less. If power consumption is not an issue for your application though, it's fine.Another point is that it's the first MCU from the RPi - trust can be an issue. In the same vein, nobody really knows the intentions of RPi for the future. How long is this product going to last, and will there be successors? Nobody knows. One related point is more general with the RPi: this is a foundation and its goal is not to consistently supply businesses with parts. It is, at best, ambiguous about that point.Now if the listed minus points are not a problem for your application and your own business, go for it. It's a great chip for what it is and again, it happens (at least for now) to be easily available, which is rare enough at the moment to be noted.

author: ataradov
author_rank: Super Contributor
timestamp: October 21, 2022, 08:24:39 pm
content: Lack of code security and general annoyance by external flash and all the variables it adds is one of the things that is stopping me from using it more.Also inefficient use of pins. There are too many pins reserved for special functions / power supplies. This often happens on new devices because vendors don't know how much they can get away with when it comes to power supply bypassing. But in this case QSPI pins would always be reserved.And yes, peripherals are lacking. Ability to implement some of them using PIO is great, but not really that useful for real projects.That being said, if I had a project that was not constrained by those things, I would not hesitate to use it in production. The IC is as stable as any other MCU.

author: WillTurner
author_rank: Regular Contributor
timestamp: October 22, 2022, 12:46:08 am
content: Some positive points in favor of the RP2040 :-good documentationlow cost and accessible development board (Raspberry Pi Pico)"open source" (an anticipated future positive for someone inheriting your design)multiple program development environments (Assembly, C/C++ SDK, FreeRTOS, Picomite and VGA BASIC variants, micropython, Fuzix)dual-core supportanticipated future development pathlots of RAM and program storage for costPIO's capable of running multiple simple tasks(last time I looked) available as an extended JLCPCB component(edits: Added to/refined list)

author: exe
author_rank: Unknown
timestamp: October 22, 2022, 07:38:11 am
content: I believe PIO makes up for the "lack of" interfaces.My complain is that it needs an external flash, which, for example, limits operational voltages to what flash supports. I also never worked with flash before, this adds some anxiety, and it's yet another IC that needs to be sourced.PS I just learned it doesn't need xtal for usb to work, that's good!

author: ataradov
author_rank: Super Contributor
timestamp: October 22, 2022, 07:50:12 am
content: Quote from: exe on October 22, 2022, 07:38:11 amWhere is this described? Even its own bootloader is very explicit on needing the external clock.And I don't think it has USB clock recovery necessary for reliable operation without a crystal. Its internal RC is definitely not good enough.

author: mino-fm
author_rank: Regular Contributor
timestamp: October 22, 2022, 09:51:16 am
content: Quote from: ataradov on October 21, 2022, 08:24:39 pmYes andQuoteyes.In the past I used Renesas RX and STM32 controllers for driving 320x240 QVGA 5,7" TFT-displays. Now these TFTs are not available anymore so my customer needs 1:1 replacement to use 640x480 VGA panels.RP2040 pico board offers all the stuff which is necessary: 150 KB RAM (6-bit colour, 2 pages), enough flash-ROM for (small) code and startup-screen picture, stable systemclock (12 MHz quarz), UART, DMA-controller and PIO-channel to double each pixel in horizontal to expand 320 to 640 pixels. DMA-controller is triggered twice starting at the same framebuffer address to double vertical lines. Two ADC-channels read out (resitive) touchscreen.It's a very cheap solution where all part are available. I don't mind that someone could copy the code of <= 100 boards.

author: tomgat
author_rank: Regular Contributor
timestamp: October 22, 2022, 02:08:03 pm
content: Quote from: SiliconWizard on October 21, 2022, 08:11:15 pmIt goes without saying that the current availability is the RP2040s best attribute. I have more than a couple POs just sitting around until 2023/24 due to component backorders, and the processor is always the most frustrating because rarely are there an easy alternative. Even worse, I have to choose to either buy the rest of the components and eat the cost of money expense, or risk something else being backordered by the time another part becomes available.The bulk of my current work at the moment is just reworks so that I can actually make/ship boards to customers. It's truly a frustrating existence because its not only not new work, but is also mind numbingly boring trying not to trigger the EMC UL paperwork nazis.

author: exe
author_rank: Unknown
timestamp: October 22, 2022, 04:31:32 pm
content: Quote from: ataradov on October 22, 2022, 07:50:12 amAh, I must be mistaken. Earlier today I think I found that somebody reported that this is working. However, I struggle to find that link, and here is one of rpi engineers says that it's unlikely to work:https://forums.raspberrypi.com/viewtopic.php?t=315464#p1887941.Well, that's a bummer. I still hope they'll pack both rp2040 die and some flash in one package, just like GigaDevice does that in their stm32 clones. Simply because it's more convenient and less board area.

author: ataradov
author_rank: Super Contributor
timestamp: October 22, 2022, 04:42:25 pm
content: Quote from: exe on October 22, 2022, 04:31:32 pmIt might work on a specific device at a specific temperature. But there is no way it would universal or reliable.Other MCUs that can work without a crystal use USB SOF (Start Of Frame) packets to synchronize their clocks. In that case the accuracy is actually better than a local crystal.Quote from: exe on October 22, 2022, 04:31:32 pmIt would be an absolute minimal requirement. But it would be nice to also not be just QSPI device in the same package, but an actual flash controller than can boot on its own.

author: b_force
author_rank: Super Contributor
timestamp: October 22, 2022, 04:43:50 pm
content: I never believe in "what's best", but I always find the suitable tool for the project.So looking from that perspective, I don't see what's inherently wrong with a RP2040.But again, that also depends on the use case.On paper a ESP32 is probably a little more powerful, but there is an argument to be made to choose for the RP2040 instead to stay with a European manufacturer for example (if that's important for you).To answer your question why we don't see more people designing with the RP2040?I don't know, I don't share that idea, I see plenty of people around me trying the RP2040.But keep in mind that it's a relatively new device on the market.So it always takes at least a year to really catch on.Plus I think people are extra careful atm because of the whole chip shortage issue.So I would rather stick to something I know that works, or even simplifying, instead of getting a board with a whole new environment.Not knowing if that will last for at least a couple of years.

author: chickenHeadKnob
author_rank: Super Contributor
timestamp: October 23, 2022, 05:43:22 am
content: Surprised no one has mentioned this in this thread yet:It doesn't appear to have a timer/capture function for its timer. In fact the timer resource is very weak. This would be a show stopper for me.Credit to Atadorov for pointing it out in an earlier thread on the pico.Also there is some bug in the ADC, missing codes or some such. There is a work-around I think.See mark omo DNL excursions:https://pico-adc.markomo.me/INL-DNL/#why-does-the-dnl-spike

author: mino-fm
author_rank: Regular Contributor
timestamp: October 23, 2022, 09:00:03 am
content: Quote from: chickenHeadKnob on October 23, 2022, 05:43:22 amI solved this problem using a PIO channel. Timer resolution can be 1/4 SystemCoreClock and max. input capture frequency 1/8 of it. Please look at 'f_mess_RP2040.c' starting at line 427 in 'pico_fmeter_GB.zip' to be found here:https://www.eevblog.com/forum/projects/pico-frequency-counter-using-rp2040/msg4177495/#msg4177495Actually I use this simple programm for four input channels: Fin, Fin/4, Fin/32 and Fref. One PIO and four DMA-channels are used to give reciprocal frequency measurements simultaneously.Thanks to Alex (Ataradov) to show me the way not to use PIOASM but brain-assembler ;-)

author: hubi
author_rank: Regular Contributor
timestamp: October 23, 2022, 09:14:29 am
content: Quote from: chickenHeadKnob on October 23, 2022, 05:43:22 amI would like to know more about the work-around for the ADC issue. I don't see how a work-around is possible, other than discarding the lower bits and oversampling to make up for it.Depending on what you need the timer/capture for, it might be possible to implement it with PIO.

author: bidrohini
author_rank: Regular Contributor
timestamp: October 23, 2022, 02:51:15 pm
content: I think Raspberry Pi pico is more user-friendly.

author: tomgat
author_rank: Regular Contributor
timestamp: October 23, 2022, 02:57:00 pm
content: Quote from: b_force on October 22, 2022, 04:43:50 pmThat is a great point! Thank you for saying it. I did not fully appreciate how new it was on the market.

author: MarkR42
author_rank: Regular Contributor
timestamp: October 23, 2022, 04:48:38 pm
content: I think the RP2040 needs an external crystal to run the firmware-update mode over USB from the boot rom.I may be wrong about this, but the boot rom source is available.It's possible that the USB can work after boot without an external crystal, but it still needs it to do the firmware load mode. You can still load the firmware without USB boot-rom mode, but you'd need to use the SWD interface pins (or alternatively put your own firmware loading system on your board)

author: ataradov
author_rank: Super Contributor
timestamp: October 23, 2022, 05:22:36 pm
content: No, USB can't work on this device without a crystal. If it could, ROM code would be the first to use this feature.

author: VEGETA
author_rank: Super Contributor
timestamp: October 23, 2022, 08:23:31 pm
content: for 1$ price on digikey and lots of support, I think it is good. most importantly for me is that it can be programmed by arduino ide using arduino code style... not many people may agree but for people who hate and suck at software, this is a good feature.by mentioning code security, you mean when you flash your stm32 mcu no one can copy the code? what do you do if you want to make your product get firmware updates?i always wanted to ask about stm32 and how easy it is for developing projects for people who suck at coding like myself? I mean what is the smallest comparable part to rp2040 and at what price? assuming project which don't need much peripherals besides i2c or spi.

author: ataradov
author_rank: Super Contributor
timestamp: October 23, 2022, 08:29:38 pm
content: Quote from: VEGETA on October 23, 2022, 08:23:31 pmYes.Quote from: VEGETA on October 23, 2022, 08:23:31 pmYou make a secure bootloader and distribute an encrypted firmware.Quote from: VEGETA on October 23, 2022, 08:23:31 pmIt depends. It is far easier to learn to program and then have all the options available. Never trying and just sticking to Arduino because you "suck" is not a good approach. Everyone sucks when they start.There is no ST device comparable in performance/price. And especially now when availability is spotty and demand is high. If you are just starting I'd be looking at STM32G0 or G4 series. But again, there is no real way to get those devices now.

author: VEGETA
author_rank: Super Contributor
timestamp: October 23, 2022, 08:44:36 pm
content: Quotecan you explain further? i mean if i have a usb connection in my product where the user connects it to pc then use a software i give him, how it is done?i never seen a tutorial for writing a bootloader or how to encrypt firmware though, just know that arduino stuff has one.Quotei used to program pic mcus in c, but my coding skills are so limited and i am really not a gifted coder. for me doing pcbs, designing hardware, power supplies and their routing, etc... is orders of magnitude easier than doing a simple code program in c. maybe i am the "hardware guy".since people talked about stm32, is it the most used option for products? i know in china it is very popular but what about say PIC or others.

author: MikeK
author_rank: Super Contributor
timestamp: October 23, 2022, 08:46:57 pm
content: Quote from: ataradov on October 23, 2022, 08:29:38 pmWhat about the cheap STM32F103 boards?https://www.aliexpress.us/item/3256802926378826.html

author: ataradov
author_rank: Super Contributor
timestamp: October 23, 2022, 08:53:02 pm
content: Quote from: VEGETA on October 23, 2022, 08:44:36 pmIt depends on the product. But generally yes, you either need a PC utility to perform the update. If you product has SD Card, you can ask users to place a specially names file on the card and insert it into the product. There are many ways.Quote from: VEGETA on October 23, 2022, 08:44:36 pmUsually you just have another tool that lets you take the raw binary and encrypt it. Tools like this are custom for the project. And that's another reason you want to get away from Arduino anyway. In a real works you will have to use other tools. I guess if all you know is Arduino, you can make an encrypting tool using it, but this is not very efficient.Quote from: VEGETA on October 23, 2022, 08:44:36 pmIt depends on how you count. If you count by units shipped, then some unknown Chinese 4-bit MCU that you never heard of will take the lead because it is used in a ton of toys and other stuff like this. Even 3 cent Padauk MCUs may be "too fancy" for such uses.But as far as more advanced designs, it sure feels like STM32 are most popular. There is a reason why everyone is cloning their peripherals.

author: ataradov
author_rank: Super Contributor
timestamp: October 23, 2022, 08:57:38 pm
content: Quote from: MikeK on October 23, 2022, 08:46:57 pmWith those boards you need to be very careful with fakes. There are a lot of them. Some don't even bother relabeling the device, just ship the cloned one. And single ICs are not readily available and where available they cost a lot more than this board shipped.LOL. Look at the very first review for the link you provided - "not original stm". And seller's response "Dear, I am very happy that you have received the order. Thanks for your support. I hope that you are satisfied with the items and look forward to doing more business with you in future.Thanks!" Double LOL.Direct performance comparison is hard. 2xCortex-M0+ at 120 MHz may beat Cortex-M3 at 72 MHz. But I doubt anyone buys those devices for their computational power, so it all boils down to peripherals.And if you are doing it just for fun, then RP2040 wins, it is much more fun to work with. STM32F103 is pretty mundane MCU, there is nothing bad or good about.

author: tomgat
author_rank: Regular Contributor
timestamp: October 24, 2022, 12:37:49 am
content: Quote from: ataradov on October 23, 2022, 08:29:38 pmMost STM32 chips for the most part are not available, and many have lead times in late 2023 to mid-2024. The only vendor with worse lead times in this regard is Microchip which has the most bizarre lead times I have ever seen on almost everything. If you listen to ST sales people, they will tell you to keep designing and that they will "get you whatever chips you need when you are ready for production", but this has not been the case for me unfortunately. I dont plan to make that mistake again, and instead will have guaranteed supply before I design.Also, on a side note, aside from the fact that they have immediate supply (ie. Their direct website shows they have 500 and 3400 reels in stock), I do think the Raspberry Pi Foundation's mission is admirable, and would like to support them if it makes business sense. I haven't seen anyone bring up any compelling reasons not to use the chip, and actually the more people that post the more it makes me start thinking this chip might have a very bright commercial future ahead of it.Finally, the most appealing thing about the RP2040 is their documentation. I dont even need a cup of coffee to read their hardware guide. Its written for idiots like me.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 24, 2022, 01:52:03 am
content: Just don't put too much hope on the ADC. If you don't have to use it, the better. For the rest, have fun. It's a fun chip. It's also very overclockable and has been proven to work at up to 400 MHz (with the right settings for Flash), but with the default settings, 250 MHz is no problem. For the lack of timers, PIO can be used of course, but also PWM.Would be great if they announced the successor of the RP2040 - with more options, for more packages, more GPIOs, more PIO state machines, a bit more RAM, and with true low power modes down to the µA range. Maybe Cortex-M4 based too, or something like that. And a much better ADC. If they manage to release that for twice the price of the RP2040, they will have me sold!

author: chickenHeadKnob
author_rank: Super Contributor
timestamp: October 24, 2022, 07:46:16 am
content: Quote from: hubi on October 23, 2022, 09:14:29 amThere are two classes of problem with the ADC. The first class results in random errors, there oversampling and averaging helps. Since the RP2040 doesn't have an internal VREF for the ADC, you either need to supply an external one or at least make sure the power is well regulated. The low noise mode actually generates more noise in the ADC than the power save mode (see Mark Omo)The second class of problem is the non-linear systemic errors due to bad implementation. The good news is that consistent non-linearity can be corrected with table look-up post processing. DNL spikes at four values (512,1536,2560,3584). INL follows a predictable sawtooth. See RP2040 datasheet section 4.9.4 pages 563-564.To address this you could brute force the correct code with a 4k by 16bit direct replacement table, improving both DNL and INL. But we can do better at little cost. You could pack the table and only store 12 bits per entry. But we can do even better. For the DNL you can simply exclude the problematic code points from your averaging.For INL you can get by with only storing signed bytes (seven bits offset plus sign) so a 4K by 8 table. You can compress this more by incorporating the regularities of the sawtooth but I wouldn't bother. The RP2040 has a decent amount of memory and you will be loading from an external ROM so...You can also dick around by adding an external R2R DAC and adding selective DC offsets to each measurement and then subtracting the offsets after performing the table look-up post processing. That spreads the measurements around and helps to average out the DNL effects. I would consider that a heroic effort though, just to rehabilitate a shitty ADC on a one dollar part. The ADC is not hopeless, just shitty.

author: hubi
author_rank: Regular Contributor
timestamp: October 24, 2022, 09:17:17 am
content: Quote from: chickenHeadKnob on October 24, 2022, 07:46:16 amThank you for the explanation. I have to think about the lookup table for a while, I'm struggling to understand how the discontinuities in the saw tooth would transform a noisy input signal.

author: tomgat
author_rank: Regular Contributor
timestamp: October 24, 2022, 12:29:22 pm
content: Quote from: chickenHeadKnob on October 24, 2022, 07:46:16 amTo your point, no $0.70 part is perfect. Also, if a person needs precision there are plenty of cost effective 16bit to 24bit sigma delta ADCs out there.