3 Commits

Author SHA1 Message Date
Robin Mueller
72d89790c3 typo 2025-08-01 11:55:44 +02:00
Robin Mueller
3ab3c2fe13 readme fix 2025-08-01 11:55:02 +02:00
Robin Mueller
a33f71217c add pwm test app 2025-08-01 11:37:37 +02:00
2 changed files with 54 additions and 9 deletions

View File

@@ -61,6 +61,16 @@ You can then adapt the files in `.vscode` to your needs.
You can use CLI or VS Code for flashing, running and debugging. In any case, take
care of installing the pre-requisites first.
### Pre-Requisites
1. [SEGGER J-Link tools](https://www.segger.com/downloads/jlink/) installed
2. [Rust `thumbv7em-none-eaibhf` toolchain](https://doc.rust-lang.org/nightly/rustc/platform-support/thumbv7em-none-eabi.html).
Use the following command to install it:
```sh
rustup target add thumbv7em-none-eabihf
```
### Using CLI with probe-rs
Install [probe-rs](https://probe.rs/docs/getting-started/installation/) first.
@@ -80,15 +90,6 @@ available for persistent flashing.
Runner configuration is available in the `.cargo/def-config.toml` file to use `probe-rs` for
convenience. `probe-rs` is also able to process and display `defmt` strings directly.
### Pre-Requisites
1. [SEGGER J-Link tools](https://www.segger.com/downloads/jlink/) installed
2. [gdb-multiarch](https://packages.debian.org/sid/gdb-multiarch) or similar
cross-architecture debugger installed. All commands here assume `gdb-multiarch`.
### Using CLI
### Using VS Code
Assuming a working debug connection to your VA416xx board, you can debug using VS Code with

View File

@@ -0,0 +1,44 @@
//! Simple PWM example
//!
//! Outputs a PWM waveform on pin PG2.
#![no_main]
#![no_std]
use cortex_m_rt::entry;
use embedded_hal::pwm::SetDutyCycle;
// Import panic provider.
use panic_probe as _;
// Import logger.
use defmt_rtt as _;
use simple_examples::peb1;
use va416xx_hal::{
clock::ClockConfigurator,
pac,
pins::PinsG,
prelude::*,
pwm::{get_duty_from_percent, PwmPin},
};
#[entry]
fn main() -> ! {
defmt::println!("-- VA108xx PWM example application--");
let dp = pac::Peripherals::take().unwrap();
// Use the external clock connected to XTAL_N.
let clocks = ClockConfigurator::new(dp.clkgen)
.xtal_n_clk_with_src_freq(peb1::EXTCLK_FREQ)
.freeze()
.unwrap();
let pinsg = PinsG::new(dp.portg);
let mut pwm = PwmPin::new(pinsg.pg2, dp.tim9, &clocks, 10.kHz()).unwrap();
//let mut delay_timer = CountdownTimer::new(dp.tim0, &clocks);
//let mut current_duty_cycle = 0.0;
pwm.set_duty_cycle(get_duty_from_percent(0.5)).unwrap();
pwm.enable();
// Delete type information, increased code readibility for the rest of the code
loop {
cortex_m::asm::nop();
}
}