Compare commits
3 Commits
va416xx-v0
...
pwm-testin
Author | SHA1 | Date | |
---|---|---|---|
![]() |
72d89790c3
|
||
![]() |
3ab3c2fe13
|
||
![]() |
a33f71217c
|
19
README.md
19
README.md
@@ -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
|
||||
|
44
examples/simple/examples/pwm_test.rs
Normal file
44
examples/simple/examples/pwm_test.rs
Normal 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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user