Author Topic: Memory mapped SPI RAM - STM32  (Read 9308 times)

0 Members and 1 Guest are viewing this topic.

Offline pyrohazTopic starter

  • Regular Contributor
  • *
  • Posts: 186
  • Country: gb
    • Harris' Electronics!
Memory mapped SPI RAM - STM32
« on: December 23, 2014, 12:58:26 am »
Hey all,

I've got a small SPI SRAM chip (23LC1024) that I've written a driver for and I'm wondering if there is anyway for me to use it as accessible memory by my microcontroller (STM32F0 Discovery)?

I'm not actually too sure on how to word it. I mean it in the sense of the microcontroller knows about and can occupy it during compile time, it just uses my driver whenever it needs to access the RAM? I know it will be really slow but I want to know if it is possible more than anything!

Thanks,
 

Offline tonyarkles

  • Regular Contributor
  • *
  • Posts: 118
Re: Memory mapped SPI RAM - STM32
« Reply #1 on: December 23, 2014, 01:29:12 am »
You're thinking of something like mmap() that you can use in Unix, right?

I've got two answers, from my admittedly limited but non-nil experience with STM32:

1: No. The chip itself doesn't have any native support for doing that. It's too complex and too much of a special feature.

2: Sort of, if you're willing to do a little bit of extra work. What the STM32 *does* support is DMA. You could pretty easily set up a buffer (in real memory), and a set of functions called something like flash_read(int sector, void* buf), and flash_write(int sector, void* buf). These would trigger an SPI read with DMA that would copy data to/from your sector.

Either way, you're not going to get mmap(), but you can get reasonably close by using some support functions that abstract away all the nitty gritty detail.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Memory mapped SPI RAM - STM32
« Reply #2 on: December 23, 2014, 01:43:33 am »
Quote
the microcontroller knows about and can occupy it during compile time, it just uses my driver whenever it needs to access the RAM?

The answer is no.

Your mcu isn't aware of compilation - that's a PC thing. So there is definitively no way for that to happen.

Having said that, for chips that support FSMC/FMC (your F0 isn't one of them), it is doable.

To use the spi sram on your chip, you have to write code to manage it.
================================
https://dannyelectronics.wordpress.com/
 

Offline pyrohazTopic starter

  • Regular Contributor
  • *
  • Posts: 186
  • Country: gb
    • Harris' Electronics!
Re: Memory mapped SPI RAM - STM32
« Reply #3 on: December 23, 2014, 03:01:17 am »
You're thinking of something like mmap() that you can use in Unix, right?

I've got two answers, from my admittedly limited but non-nil experience with STM32:

1: No. The chip itself doesn't have any native support for doing that. It's too complex and too much of a special feature.

2: Sort of, if you're willing to do a little bit of extra work. What the STM32 *does* support is DMA. You could pretty easily set up a buffer (in real memory), and a set of functions called something like flash_read(int sector, void* buf), and flash_write(int sector, void* buf). These would trigger an SPI read with DMA that would copy data to/from your sector.

Either way, you're not going to get mmap(), but you can get reasonably close by using some support functions that abstract away all the nitty gritty detail.

Yup pretty much! What I really want it to be able to access the external SPI RAM as a standard array e.g. ExternalRam[10] = 5; or something along them lines. Obviously the Name[Index] notation is very C based but could I set the start of the external ram as a virtual address, much higher than the largest address within the STM32 and then somehow intercept whenever the processor tries to access that area of memory, with a function to get the data off the SPI chip? I'm find with blocking reads/writes to help with thread safety etc.

Quote
the microcontroller knows about and can occupy it during compile time, it just uses my driver whenever it needs to access the RAM?

The answer is no.

Your mcu isn't aware of compilation - that's a PC thing. So there is definitively no way for that to happen.

Having said that, for chips that support FSMC/FMC (your F0 isn't one of them), it is doable.

To use the spi sram on your chip, you have to write code to manage it.

I've looked into the FSMC/FMC stuff but there are SO MANY pins required and they only support parallel rams which tend (in packaged I can solder...) to be large. I've actually got the STM32F439 discovery but I'm waiting for support within CoIDE to teach myself about FMC and the LCD interface.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf