cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to write FSMC registers

Wasilewski.Piotr
Associate III
Posted on June 25, 2015 at 16:44

Hello!

My name is Peter and my hobby is electronics, programming and robotics. Recently I got interested in STM32 and decided to build my own evaluation board. Currently I have a problem with FSMC. I want to drive an LCD display through it, but I cannot change the registers' values. Of course the clock for FSMC is on. I have even tried to change them directly (manually) in coocox debug view,  with no result. Can You tell me, what I need to turn on (except the clock source) to be able to write these registers ? 

One more thing : I have checked the errata sheet, but i couldn't find my case there.

I almost fotgot  - my chip is STM32f103VCT6, and I have changed it today so it's not broken.

Greetings,

Peter
7 REPLIES 7
Posted on June 25, 2015 at 19:35

Think about presenting code.

Does the FSMC bit in AHBENR actually assert? There are members of the STM32F1 family that don't support FSMC

Try

RCC->AHBENR = 0xFFFFFFFF;

printf(''%08X\n'', RCC->AHBENR);

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Wasilewski.Piotr
Associate III
Posted on June 25, 2015 at 21:22

Thank You for reply.

Here's the code (I'm used to writing using the registers, not the SPL, but it's the first time I'm using FSMC so I decided to modify a function from example of NAND memory)

void
FSMC_NAND_Init(
void
)
{
GPIO_InitTypeDef GPIO_InitStructure;
FSMC_NANDInitTypeDef FSMC_NANDInitStructure;
FSMC_NAND_PCCARDTimingInitTypeDef p;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE , ENABLE);
/* CLE, D0-D3, NOE, NWE - NAND pin configuration*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_14 | GPIO_Pin_15 |
GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* D4->D7 - NAND pin configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/*-- FSMC Configuration ------------------------------------------------------*/
p.FSMC_SetupTime = 0x1;
p.FSMC_WaitSetupTime = 0x2;
p.FSMC_HoldSetupTime = 0x1;
p.FSMC_HiZSetupTime = 0x0;
FSMC_NANDInitStructure.FSMC_Bank = FSMC_Bank2_NAND;
FSMC_NANDInitStructure.FSMC_Waitfeature = FSMC_Waitfeature_Enable;
FSMC_NANDInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
FSMC_NANDInitStructure.FSMC_ECC = FSMC_ECC_Disable;
FSMC_NANDInitStructure.FSMC_ECCPageSize = FSMC_ECCPageSize_8192Bytes;
FSMC_NANDInitStructure.FSMC_TCLRSetupTime = 0x00;
FSMC_NANDInitStructure.FSMC_TARSetupTime = 0x00;
FSMC_NANDInitStructure.FSMC_CommonSpaceTimingStruct = &p;
FSMC_NANDInitStructure.FSMC_AttributeSpaceTimingStruct = &p;
FSMC_NANDInit(&FSMC_NANDInitStructure);
/* FSMC NAND Bank Cmd Test */
FSMC_NANDCmd(FSMC_Bank2_NAND, ENABLE);
}

0690X0000060324QAA.jpg 0690X00000602voQAA.jpg As You can see after initialization the registers stay untouched. But after Your piece of code the registers of RCC are all 1 as they should be : 0690X00000602vpQAA.jpg ''There are members of the STM32F1 family that don't support FSMC'' Actually I have checked it, and STM32f103VCT6 has the FSMC, so i don't know what I'm doing wrong. Greetings, Peter From: clive1 Posted: Thursday, June 25, 2015 7:35 PM Subject: Unable to write FSMC registers

Think about presenting code.

Does the FSMC bit in AHBENR actually assert? There are members of the STM32F1 family that don't support FSMC Try RCC->AHBENR = 0xFFFFFFFF; printf(''%08 X'', RCC->AHBENR);
Posted on June 25, 2015 at 22:07

May be it's the tool?

Suggest you read the FSMC Bank 2 register directly in your own code, and decode/decompose them there.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Wasilewski.Piotr
Associate III
Posted on June 25, 2015 at 22:52

Thank You for reply!

Hmmm it seems You are right ! It has to be the tool, because the values of registers differ before and after writing to them. It's veird becasue I have tried another IDE - eclipse, ant there was the same problem. Anyway, I'll try to read them with keil, and I'll inform You of the results. 

Again thank You for this idea !

Greetings,

Peter

Posted on June 25, 2015 at 22:56

Can't you just print them out the console (USART or SWV), or copy to a memory array you can dump? Or do a memory (hex) view over the peripheral space instead of the peripheral viewer?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Wasilewski.Piotr
Associate III
Posted on June 25, 2015 at 23:11

Hmmm that's a good idea too. I'll do as You say, but first i have to learn how to print the result in coocox 😉 

Wasilewski.Piotr
Associate III
Posted on June 26, 2015 at 13:39

0690X000006031zQAA.jpg

It works ! 🙂