Skip to main content
MNapi
Senior II
June 12, 2024
Question

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

 

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 ?

 

 

 

This topic has been closed for replies.

20 replies

Tesla DeLorean
Guru
June 12, 2024

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
MNapi
MNapiAuthor
Senior II
June 12, 2024

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.

Tesla DeLorean
Guru
June 12, 2024

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
MNapi
MNapiAuthor
Senior II
June 12, 2024

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

Tesla DeLorean
Guru
June 12, 2024

>>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 (See Profile) Up vote any posts that you find helpful, it shows what's working..