Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RMT] clk_divider of TxChannelConfig doesn't work. #2122

Closed
Tnze opened this issue Sep 9, 2024 · 1 comment
Closed

[RMT] clk_divider of TxChannelConfig doesn't work. #2122

Tnze opened this issue Sep 9, 2024 · 1 comment
Labels
bug Something isn't working peripheral:rmt RMT peripheral
Milestone

Comments

@Tnze
Copy link

Tnze commented Sep 9, 2024

Change the clk_divider and measure the output signal, the frequency doesn't change.

#![no_std]
#![no_main]

use esp_backtrace as _;
use esp_hal::{
    gpio::Io,
    rmt::{PulseCode, Rmt, TxChannel, TxChannelConfig, TxChannelCreator},
    clock::ClockControl, delay::Delay, peripherals::Peripherals, prelude::*, system::SystemControl,
};

extern crate alloc;
use core::mem::MaybeUninit;

#[global_allocator]
static ALLOCATOR: esp_alloc::EspHeap = esp_alloc::EspHeap::empty();

fn init_heap() {
    const HEAP_SIZE: usize = 32 * 1024;
    static mut HEAP: MaybeUninit<[u8; HEAP_SIZE]> = MaybeUninit::uninit();

    unsafe {
        ALLOCATOR.init(HEAP.as_mut_ptr() as *mut u8, HEAP_SIZE);
    }
}

#[entry]
fn main() -> ! {
    let peripherals = Peripherals::take();
    let system = SystemControl::new(peripherals.SYSTEM);

    let clocks = ClockControl::max(system.clock_control).freeze();
    let delay = Delay::new(&clocks);
    init_heap();

    esp_println::logger::init_logger_from_env();

    let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);

    let rmt = Rmt::new(peripherals.RMT, 32.MHz(), &clocks).unwrap();

    let tx_config = TxChannelConfig {
        clk_divider: 32,
        idle_output_level: false,
        idle_output: false,
        carrier_modulation: true,
        carrier_high: 13,
        carrier_low: 13,
        carrier_level: true,
    };
    let mut channel = rmt.channel0.configure(io.pins.gpio0, tx_config).unwrap();

    let S = PulseCode {
        level1: true,
        length1: 9000,
        level2: false,
        length2: 4500,
    };
    let C = PulseCode {
        level1: true,
        length1: 620,
        level2: false,
        length2: 20000,
    };
    let E = PulseCode {
        level1: true,
        length1: 620,
        level2: false,
        length2: 1643,
    };
    let Z = PulseCode {
        level1: true,
        length1: 620,
        level2: false,
        length2: 540,
    };
    let O = PulseCode {
        level1: true,
        length1: 620,
        level2: false,
        length2: 1620,
    };
    let data = [
        S, // start
        O, Z, Z, // mode
        O, // on
        Z, Z, // wind
        O, // swing
        Z, // sleep
        Z, Z, Z, Z, // temp
        Z, Z, Z, Z, Z, Z, Z, Z, // timer
        Z, // super
        O, // light
        Z, // health,
        Z, // dry,
        Z, // ventilation
        Z, Z, Z, O, Z, O, Z, Z, O, Z, // fixed
        C, // connect
        O, // v-swing
        Z, Z, Z, // fixed
        O, // h-swing
        Z, Z, Z, // fixed
        O, Z, // temp display
        Z, Z, Z, O, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, // fixed
        Z, // save-power
        Z, // fixed
        O, Z, O, Z, // checksum
        E,
        PulseCode::default(),
    ];
    // let checksum = (0b001 - 1) + (0b0000) + 5 + 1 + 0 + 0 - 1;

    delay.delay(1.secs());
    loop {
        log::info!("Hello world!");
        // let transaction = channel.transmit(&data);
        // channel = transaction.wait().unwrap();
        let contin_trans = channel.transmit(&data);
        channel = contin_trans.wait().unwrap();
        delay.delay(500.millis());
    }
}
@github-project-automation github-project-automation bot moved this to Todo in esp-rs Sep 9, 2024
@MabezDev MabezDev added bug Something isn't working peripheral:rmt RMT peripheral labels Sep 9, 2024
@MabezDev MabezDev added this to the 0.21.0 milestone Sep 9, 2024
@Tnze
Copy link
Author

Tnze commented Sep 10, 2024

According to the TRM, 34.3.1 chapter, Figure 34-1 RMT Architecture, the Div Counter doesn't effect the Carrier_Generator.

@Tnze Tnze closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working peripheral:rmt RMT peripheral
Projects
Archived in project
Development

No branches or pull requests

2 participants