cancel
Showing results for 
Search instead for 
Did you mean: 

External SRAM 16-bit access - elucidation required [SOLVED]

johann23
Associate II
Posted on April 19, 2013 at 10:50

Hello,

I've doubts regarding

the access of an external SRAM (IS61WV102416BLL) connected to the FSMC bus that has the following spe

cifications

. This SRAM is organized as 1024K

x 16-bit

.

My assumption is,

by using the following code (SRAM is mapped to

0x

64000000)

, I would be able to

access t

wo consecutive

half-words (16-bit wide)

:

1.
volatile
uint16_t * p_sram_1 = (
volatile
uint16_t *)0x64000000;
2.
volatile
uint16_t * p_sram_2 = (
volatile
uint16_t *)0x64000001;
3.
4.
*p_sram_1 = 0xBBAA;
5.
*p_sram_2 = 0xDDCC;
6.
7.
uint16_t data1 = *p_sram_1;
8.
uint16_t data2 = *p_sram_2;

I expect t

hat data1

w

ill contain

0xBBAA and data2, 0xDDCC

. But when I execute this code, data1 contains

0xCCAA

instead of 0xBBAA. This let me think that each address accesses one byte

instead of two bytes that I expected.

Am I totally wrong with my expectations or is

the FMS

C

bus translating unalign

ed addresses accesses in upper byte or lower byte access

es?

Thank you for your help.

#external-sram #fsmc #access
5 REPLIES 5
frankmeyer9
Associate II
Posted on April 19, 2013 at 11:08

Probably because you actually meant :

volatile uint16_t * p_sram_1 = (volatile uint16_t *)0x64000000;

volatile uint16_t * p_sram_2 = (volatile uint16_t *)0x64000002;

johann23
Associate II
Posted on April 19, 2013 at 12:40

Thank

you

for you

r answer.

What you're s

aying is

:

  • Ad

    dress 0x6400000

    0

    points to b

    yte 0

  • Address 0x64000001 points to byte 1

  • Address 0x6400000

    2 points to byte 2

  • Address 0x64000003 points to byte 3

Since this external SRAM

is connected

to the microcontroller using

a 20-bit address bus, the

memory range is

0x64000000

to 0x640FFFFF

,

which means that I can access only 1

MBytes instead of 2MBytes, w

hich is the size of the SRAM

, i

sn't it

?

What

am I doing wrong

?

frankmeyer9
Associate II
Posted on April 19, 2013 at 13:02

It's not related to the addressable space.

I mean, the locations your pointers p_sram_1 and p_sram_2 are referring to do overlap.

With writing to *p_sram_2, you overwrite one byte of the location where p_sram_1 points to.

I believe it is not what you intended to do.

Posted on April 19, 2013 at 13:11

>

What you're s

aying is

:

  • Ad

    dress 0x6400000

    0

    points to b

    yte 0

  • Address 0x64000001 points to byte 1

  • Address 0x6400000

    2 points to byte 2

  • Address 0x64000003 points to byte 3

Yes.

Since this external SRAM

is connected

to the microcontroller using

a 20-bit address bus, the

memory range is

0x64000000

to 0x640FFFFF

,

which means that I can access only 1

MBytes instead of 2MBytes, w

hich is the size of the SRAM

, i

sn't it

?

No. The address used in software is byte address, but the address emitted by the FSMC onto address lines is word address. The remaining bit is emitted by hardware as the /UBand  /LB byte selection signal (FSMC_BLN0 and FSMC_BLN1).

This all provided that the hardware is connected and software configured properly.

What

am I doing wrong

?

Y

ou

don't

read the manual carefully en

ough.

You did not

tell us which model do you use, but

if it is e.g. STM32F4xx, in RM0090 read chapter 32.4.1 NOR/PSRAM address mapping,

especially table 186 and the remark under i

t.

JW

johann23
Associate II
Posted on April 19, 2013 at 13:31

Thank you Jan.

Indeed, I missed the chapter 31.4.1

in

R

M

0033

which answers my question.

By

the way,

I am using

the

STM32F205 model.