19 questions
3
votes
1
answer
107
views
Rust optimizes away all the interrupt/exception handlers from riscv-rt
I'm trying to build a simple app using riscv-rt for a riscv32imac target by following the steps from https://docs.rs/riscv-rt/0.14.0/riscv_rt/. What I need is a couple of external interrupt handlers. ...
1
vote
1
answer
45
views
Cannot share the board between LED matrix and button in microbitV2 using rust
I am learning embedded rust by trying to recreate microbitV2 library using nrf52833_hal but got stuck.
pub struct LedMatrix {
col: [Pin<Output<PushPull>>; 5],
row: [Pin<Output&...
0
votes
1
answer
87
views
Can't set frequency more than 48MHz on STM32F767ZI
I configure the RCC for 48 MHz as follows:
rcc.cr.modify(|_, w| w.hseon().on());
while rcc.cr.read().hserdy().is_not_ready() {}
println!("{:b}", rcc.cr.read().bits());
...
0
votes
1
answer
86
views
PWM configured via DMA does not work properly at high speeds
I have set RCC on STM32F767ZI to 48 MHz (when setting to a higher frequency an error occurs, although in CubeMX with the same settings there is no error).
rcc.cr.modify(|_, w| w.hsebyp().set_bit())...
0
votes
1
answer
94
views
How to control duty cycle via DMA on Rust?
I wrote my code based on this topic, but it is not work. I'm using the stm32f7xx_hal crate, but I think the logic of my program is similar to the code from the example. My problem is that the duty ...
0
votes
1
answer
270
views
Rust Embassy SimplePwm waveform functions don't work as intended
Duty-cycle behaves strangely at high frequencies.
While at 20 KHz the error is barely noticeable
PWM of 20 KHz
At 6 MHz it becomes obvious
PWM of 6 MHz
I use the STM32F11ce6 microcontroller.
Clock ...
0
votes
1
answer
170
views
Using ufmt::uwriteln! within a function
I am using rust with #![no_std]. I want to use ufmt::uwriteln!(&mut serial, "Hello world\r").unwrap(); in function. I need to pass &mut serial to this function, but don't know how to ...
1
vote
0
answers
322
views
Difference between panic = "abort" in Cargo.toml profile and "panic-strategy": "abort" in Rust target spec file
I'm working on a small embedded Rust project based on the https://github.com/Rahix/avr-hal-template.git for AVR cpus.
I want to add some unit tests, so I removed the test = false line from the Cargo....
1
vote
0
answers
318
views
How to share the rust embedded hal delay between different devices?
I'm trying to write an embedded stm application in rust. In this particular application I'm using the sx127x_lora crate. However this requires a delay as a parameter so I pass the delay from cortex_m::...
0
votes
1
answer
124
views
Reference the same variable multiple times without borrowing or cloning
Currently, I am redefining the same variable (dp) multiple times to make the program work. However, this feels wrong, and I would think there would be a much better way to do this. For context, I am ...
1
vote
1
answer
341
views
Is there a way to not "move" i2c when using sh1106 (and similar) in Rust
I am quite new to Rust and are diving into the relatively complicated embedded programming, perhaps thats my problem, please bear with me...
I use the RPi Pico, with an SH11106 display over i2c, using ...
0
votes
1
answer
266
views
Equivalent of "tone()" in avr_hal
I'm trying to translate the following code from the Arduino IDE Into Rust using the avr_hal crate to make a passive buzzer play notes:
#include "pitches.h"
// notes in the melody:
int ...
1
vote
1
answer
362
views
Set alternate mode for stm32 rust HAL
I want to set alternate mode for AP10 of stm32f411 by rust HAl. My code looks like this:
let rx_pin = gpioa.pa10.into_alternate();
But it has multiple impl:
= note: multiple `impl`s satisfying `...
4
votes
2
answers
3k
views
Get elapsed time since some instant in embedded rust
I started making a program in rust, and I want to be able to get the elapsed time since some instant. Here's how the std library does it.
use std::time::{Duration, Instant};
use std::thread::sleep;
...
2
votes
0
answers
751
views
Embedded Rust & Embassy | Analog measurement - ADC & DMA | STM32F7
My setup:
The signal is connected to the analog input of the STM32F767.
ADC sampling rate should be at least 192kHz because input signal frequency is between 1Hz and 40kHz.
Also STM32 connected to ...
0
votes
0
answers
293
views
Rust stm32f7 | ADC & DMA at 192 kHz sample rate
I’m trying to implement ADC conversion from gpio analog input at the sample rate of 192 kHz. Then I want to send the array of samples over tcp to the client.
My question:
How to implement ADC ...
1
vote
0
answers
634
views
Rust no_std ESP32 hal | ADC & DMA at 192 kHz sample rate
I’m trying to implement ADC conversion in a non blocking mode using DMA from gpio analog input at the sample rates: 192kHz.
My questions:
How to be implemented ADC in non-blocking mode (DMA). ...
0
votes
1
answer
1k
views
Modifying a specific memory address in Rust
I declared pointers (memory addresses) and I am able to read values like that in Rust:
let psram = 0x60000000 as *const u32;
let psramh = 0x60000000 as *const u16;
let psramb = 0x60000000 as *const u8;...
2
votes
1
answer
171
views
Enforcing trait implemented only on given type size in Rust
For embedded/IO use case in Rust, I need to build a lib to receive/transmit messages using a small fixed size buffer (must not exceed it). The messages themselves will be defined by the user of the ...