Open Luctins opened 2 months ago
Update: I got memory mapped mode to work with the following register changes:
const OSPI_BASE: *mut () = (0x1001400 + 0x06000000 + 0x40000000) as *mut ();
const OCTOSPI1_DEV: Octospi = unsafe { Octospi::from_ptr(OSPI_BASE) };
fn test_ram() {
//...
while OCTOSPI1_DEV.sr().read().busy() {
info!("wait ospi busy");
}
OCTOSPI1_DEV.ccr().modify(|r| {
r.set_isize(embassy_stm32::pac::octospi::vals::SizeInBits::_8BIT);
r.set_adsize(embassy_stm32::pac::octospi::vals::SizeInBits::_24BIT);
r.set_admode(embassy_stm32::pac::octospi::vals::PhaseMode::FOURLINES);
r.set_imode(embassy_stm32::pac::octospi::vals::PhaseMode::FOURLINES);
r.set_dmode(embassy_stm32::pac::octospi::vals::PhaseMode::FOURLINES);
});
OCTOSPI1_DEV.cr().modify(|r| {
r.set_fmode(FunctionalMode::MEMORYMAPPED);
r.set_dmaen(false);
r.set_en(true);
});
OCTOSPI1_DEV.tcr().modify(|r| {
r.set_dcyc(6);
});
//...
}
But I would really like to know if there's an officially supported way to do this.
I'm trying to use the memory mapped mode of the OCTOSPI available on the CPU (
stm32h563zi
) at memory address0x9000_0000
with a 64mbit QuadSPI (APM6404L) but trying to access this memory range trows a hardfault.My current attempt is this:
Currently I can read and write to the memory chip using
command
,[blocking_]write
and[blocking_]read
without problem.I'm accessing the registers by myself because I couldn't find a high level config to enable memory mapped mode, and most examples I found online were C and accessed the registers directly.
Am I missing something to make this work, like a linker script?