Programming PIC32 Microcontroller with Rust
gill.net.in
gill.net.in
[1] https://blog.adacore.com/how-to-prevent-drone-crashes-using-...
It is certainly possible to make an 8-bit core based on RISC principles (ex: AVR), but the PIC wasn't. Classic PIC has a hard-earned reputation for awful compiler support.
Did it? I didn't realize.
Though I did find at least one bug in the code generation for the compiler we were using ~15 years ago... Something funny was happening with the generation of an if statement, don't remember the rest of the details.
They struggled with C8 or something, then they purchased HiTech C and renamed it XC8 (and 16). Then I think expanded it to the DSP33s and PIC32 which for some reason are drastically different. Then at some point they forced everything into MPLABX (netbeans) and Harmony code generation… it’s never been good.
I hate that I’ve never found anything I completely love.
They have niches though.
Those parts didnt support stack variables, so that compiler would analyze the call tree and essentially use global (fixed address) variables for locals, but it could reuse them in different functions.
Yes a pain for the compiler, but at least one did it really well.
It’s the only one of Microchip’s compilers that’s not GCC-based, which can be a pain. Also I remember at -O0, the generated code is just huge and inefficient.
Luckily the assembly language is one of the nicest in existence.
Turns out that PIC assembly is super fun.
Ah, this I totally agree with. Brought back memories from my undergrad days, programming with PIC was a joy compared to AVR in assembly.
https://github.com/vlisivka/rust-arduino-blink - just minimal blink
https://github.com/vlisivka/rust-arduino-hello-world - just print "Hello, world" to serial port.
https://github.com/vlisivka/rapt - little shell for pin testing (turning them on/off via serial port).
Yes. I’ve been waiting for this for a few years.
For someone to dumb down and actually support this process.
I can’t leave C and my IDEs behind. I can’t jump into a new product with RUST if there is no official support anywhere. I’m not payed to tinker with a setup, I’m paid to make embedded products that solve customer problems.
Give me an IDE. Or someone make a serious effort at Rust with VS Code or whatever IDE and some real package support. I’ll be there with dollars in hand.
I look at how much money and effort things like Zephyr or MicroPython get and it’s so strange that things with a ton of competition already or niche toys draw bigly - but something like Rust for embedded gets a couple of people making crates here or there.
The PIC16C84 was one of the (if not the) first MCU chips to use EEPROM (precursor to flash memory), so I didn't need an eraser. It became a favorite of hobbyists. Programs were so simple, that assembly language wasn't really much of a barrier. I only started using C later, in fact, to teach myself C programming.
Before that, I made a board that combined an 8031 (8051 without built-in ROM) and a 28 pin EEPROM. My programmers hung on the parallel printer port of a MS-DOS machine, and were controlled by code I wrote in Turbo Pascal. Ah, the days. ;-)
I mostly use Great Cow BASIC[1] with 16F and 18F series PICs on my projects. My workflow[2] is to connect the PIC to a breadboard as in the article, then connect the Pi to the pins on the breadboard using dupont cables. I then ssh into the Pi, write my program in vim on the Pi, compile the program using the command-line version of GCB, and flash it to the PIC using Pickle. (Not sure if this workflow would work in this case, however--will the pic32-rs compiler work on ARM?)
As a bonus, most PICs can be configured so the program pins also are serial UART pins, making it possible to use the same connection for serial I/O between the PIC and the Pi.
[0]-https://wiki.kewl.org/dokuwiki/projects:pickle
The site likes to strip off leading "Why ...", "How ... ", and "9 ways to ...", as clickbait. Isn't "...in Rust" often just a peculiarly HNish variety?
So "...in Rust" makes those people aware that Rust now is also an option, alongside Assembly, Basic, Pascal and C.
Does it really mean "... with LLVM"? Maybe say that.
So the question is really, what should be done to these titles to make them not clickbait? My proposal was "with LLVM", for programming microcontrollers. If you have a better idea, say.
It has been Ruby, Elixir, Erlang, Clojure, Go, and now Rust, probably it will be Zig after it gets 1.0, or something else even more fancy.
Besides,
> Otherwise please use the original title, unless it is misleading or linkbait; don't editorialize.
I haven't seen Dan complaining about it.