cancel
Showing results for 
Search instead for 
Did you mean: 

any idea why it is freezing executing *mem_addr = aTxBuffer[index];

MNapi
Senior III

 

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 ?

 

 

 

20 REPLIES 20

What are you writing too? A RAM or the NOR FLASH?

What's the Write Template for the Memory Mapping look like?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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.

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?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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

 

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MNapi
Senior III

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
}
}

>>I ask if there is different way to write the code

Well that's sure to be entertaining..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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