You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to interface stm32f3discovery with I2C F-RAM(MB85RC256V).
Below is the snippet of the code.
//! Example of using I2C.
//! Scans available I2C devices on bus and print the result.
//! Appropriate pull-up registers should be installed on I2C bus.
//! Target board: STM32F3DISCOVERY
#![no_std]
#![no_main]
use panic_halt as _;
use core::ops::Range;
use cortex_m_rt::entry;
use cortex_m_semihosting::{hprint, hprintln};
use stm32f3xx_hal_v2::{self as hal, pac, prelude::*, i2c::Error};
const VALID_ADDR_RANGE: Range = 0x08..0x78;
const MEMORY_ADDRESS: u16 = 0x0000; // Address to write/read data to/from
I am trying to interface stm32f3discovery with I2C F-RAM(MB85RC256V).
Below is the snippet of the code.
//! Example of using I2C.
//! Scans available I2C devices on bus and print the result.
//! Appropriate pull-up registers should be installed on I2C bus.
//! Target board: STM32F3DISCOVERY
#![no_std]
#![no_main]
use panic_halt as _;
use core::ops::Range;
use cortex_m_rt::entry;
use cortex_m_semihosting::{hprint, hprintln};
use stm32f3xx_hal_v2::{self as hal, pac, prelude::*, i2c::Error};
const VALID_ADDR_RANGE: Range = 0x08..0x78;
const MEMORY_ADDRESS: u16 = 0x0000; // Address to write/read data to/from
fn check_i2c_error(error: Error) -> Result<(), ()> {
match error {
Error::Arbitration => {
hprintln!("Arbitration loss occurred").unwrap();
Err(())
}
Error::Bus => {
hprintln!("Bus error occurred").unwrap();
Err(())
}
Error::Busy => {
hprintln!("Bus is busy").unwrap();
Err(())
}
Error::Nack => {
hprintln!("NACK received during transfer").unwrap();
Err(())
}
_ => {
hprintln!("Unknown error occurred").unwrap();
Err(())
}
}
#[entry]
fn main() -> ! {
let dp = pac::Peripherals::take().unwrap();
// Example read operation
let mut data_read = [0u8; 3];
if let Err(e) = i2c.read(fram_address, &mut data_read) {
hprintln!("Error reading data: {:?}", e).unwrap();
}else{
hprintln!("Success!!").unwrap();
}
}
I always receive "Bus error occurred" while trying to read data.
I have used Arduino and F-RAM which works as expected.
I would truly appreciate any help in this matter.
The text was updated successfully, but these errors were encountered: