Current DateTime using microbit-v2 crate

let scl = board.i2c_external.scl.into_floating_input().degrade();
let sda = board.i2c_external.sda.into_floating_input().degrade();
let i2c = twim::Twim::new(
       board.TWIM0,
       twim::Pins { scl, sda },
       twim::Frequency::K100, // 100 kHz I2C frequency );
 // Initialize the DS3231 RTC
let mut rtc = Ds323x::new_ds3231(i2c);
let datetime = NaiveDate::from_ymd_opt(2024, 12, 24).unwrap();
 rprintln!("{:?}", datetime);
    
let result = match rtc.set_date(&datetime) {
      Ok(r) => r,
       Err(e) => {
            rprintln!("Error {:?}", e);
       }
};

I want to be able to get the date (current date time), but I am finding it quite difficult. Here 'rtc.set_date' I keep on getting the error Error Comm(DMABufferNotInDataMemory).

From what I've read on the crate, .degrade() is converting variables scl and sda from P0_26<Input<Floating>> to Pin<Mode> rather than Pin<Input<Floating>> as required by the Pin struct from twim::Twim::new(). Maybe .degrade() is stripping away useful information the Pins struct requires so try initializing without it.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.