Coder Social home page Coder Social logo

hello-wch's People

Contributors

noxime avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hello-wch's Issues

I meet a very strange BUG, help wanted !

I compile hello-wch and flash it to ch32v003 chip, and it works ok (LED blink):

#[entry]
fn main() -> ! {
    let RCC_APB2PCENR: *mut u32 = 0x4002_1018 as _;
    let GPIOC_CFGLR: *mut u32 = 0x4001_1000 as _;
    let GPIOC_OUTDR: *mut u32 = 0x4001_100C as _;

    unsafe {
        // Enable clocks to the GPIOC bank
        RCC_APB2PCENR.write_volatile(0b10000);
        // Set pin 1 to output
        GPIOC_CFGLR.write_volatile(0b0001_0000);

        loop {
            // Set pin 1 to high
            GPIOC_OUTDR.write_volatile(0b1_0);
            riscv::asm::delay(1_000_000);

            // Set pin 1 to low
            GPIOC_OUTDR.write_volatile(0b0_0);
            riscv::asm::delay(2_000_000);
        }
    }
}

when I change the 2 delay value to the same value, it also works:

diff --git a/src/main.rs b/src/main.rs
index f65de71..addfb51 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -19,11 +19,11 @@ fn main() -> ! {
         loop {
             // Set pin 1 to high
             GPIOC_OUTDR.write_volatile(0b1_0);
-            riscv::asm::delay(1_000_000);
+            riscv::asm::delay(2_000_000);
 
             // Set pin 1 to low
             GPIOC_OUTDR.write_volatile(0b0_0);
-            riscv::asm::delay(1_000_000);
+            riscv::asm::delay(2_000_000);
         }
     }
 }

But when I change only one delay value, it does not work (LED not blink):

diff --git a/src/main.rs b/src/main.rs
index f65de71..1a1f0d9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -23,7 +23,7 @@ fn main() -> ! {
 
             // Set pin 1 to low
             GPIOC_OUTDR.write_volatile(0b0_0);
-            riscv::asm::delay(1_000_000);
+            riscv::asm::delay(2_000_000);
         }
     }
 }

I do not know what is wrong. Help wanted !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.