2024-06-11 05:41 PM
I have this code it transfers to 0x90000000 (OSPI) data
__IO uint8_t *mem_addr;
/* USER CODE BEGIN 2 */
HAL_OSPI_MemoryMapped(&hospi1, &sMemMappedCfg)
mem_addr = (uint8_t *)(OCTOSPI1_BASE + address);
for (index = 0; index < BUFFERSIZE; index++)
{
*mem_addr = aTxBuffer[index];
mem_addr++;
}
it compiles and runs fine but freezes on *mem_addr = aTxBuffer[index];
has anybody seen something like this ?
2024-06-11 09:26 PM
What are you writing too? A RAM or the NOR FLASH?
What's the Write Template for the Memory Mapping look like?
2024-06-12 05:12 AM
to NOR FLASH
actually I have this code working on another board 32L4P5 Discovery and working in Keil on H7 chip
when I move to CubeIDE and H7 chip board it stops
I wonder if I could just replace by memcpy
I do not have problems with QSPI
but OSPI seems to give a lot of problems.
2024-06-12 05:21 AM
I'm not sure how this would work, the template would have to be a PAGE WRITE, and you'd need to wait for the NOR FLASH to come ready ie SR.WIP = 0
Also how would the WRITE ENABLE work?
2024-06-12 06:42 AM
here is a guy
https://www.youtube.com/watch?v=vo92RHKxYA4
he is using memcpy, you can see it at about 13 min
he modified and expended a lot of original STM tutorials
2024-06-12 06:57 AM
Ok, but he's doing a memcpy *READ* out of the external memory, and you're attempting to memcpy *WRITE* into external memory (0x90000000 + addr)
The string is being written into the QSPI by the External Loader because the compiler/linker placed it there.
2024-06-12 07:29 AM
I tried https://chatgpt.com/
I ask if there is different way to write the code
this might be the way to go:
#include "stm32f7xx_hal.h"
#define OSPI_BASE_ADDRESS 0x90000000 // Base address of OSPI memory
#define OSPI_SIZE 0x1000000 // Size of OSPI memory (for example, 16 MB)
void OSPI_MemoryWrite(uint32_t *src_address, uint32_t offset, uint32_t size) {
uint32_t *ospi_address = (uint32_t *)(OSPI_BASE_ADDRESS + offset);
HAL_OSPI_Transmit(&hospi1, src_address, ospi_address, size, HAL_MAX_DELAY);
}
int main(void) {
HAL_Init();
// Initialize OSPI and configure it for memory mapped mode
// Example initialization code for OSPI
// Configure OSPI to mapped mode and set up appropriate timings, memory width, etc.
// Example data to be written to OSPI memory
uint32_t data[] = {0x11223344, 0xAABBCCDD, 0x55667788};
uint32_t data_size = sizeof(data);
uint32_t offset = 0x1000; // Example offset within OSPI memory
// Write data to OSPI memory
OSPI_MemoryWrite(data, offset, data_size);
while (1) {
// Main application loop
}
}
2024-06-12 08:31 AM
>>I ask if there is different way to write the code
Well that's sure to be entertaining..
2024-06-12 09:29 AM
2024-06-13 05:54 AM
thanks but this is exactly the same code I am trying
everything is working except the memory mapped in CubeIDE
I cannot figure out why it does not work and freezes in this code
*mem_addr = aTxBuffer[index];
The same project, memory mapped works fine in Keil.
The code and example is provided by STM