cancel
Showing results for 
Search instead for 
Did you mean: 

error in the STR9 library?..............91x_emi.c

hugh2
Associate II
Posted on July 18, 2008 at 10:14

error in the STR9 library?..............91x_emi.c

2 REPLIES 2
hugh2
Associate II
Posted on May 17, 2011 at 09:54

By carefully debugging our emi and enet initialisation we found that the void EMI_StructInit( EMI_InitTypeDef *EMI_InitStruct) function in 91x_emi.c does not initialise the EMI_BurstModeWrite_TransferLength element.

Even though the EMI_BurstModeWrite_Selection is set to EMI_NonBurstModeWrite we think EMI_BurstModeWrite_TransferLength must also be set to EMI_Write_4Data.

The code ''EMI_InitStruct->EMI_BurstModeWrite_TransferLength = EMI_Write_4Data''; should be added to the EMI_StructInit() function.

In general _ALL_ the elements of a structure should be initialised in the StructInit() functions otherwise very strange results will occur. As the various StructInit() calls are processed at the beginning of the code the structure elements are pushed into the stack area. Any element not implicitly set will pick up a random value left there by a previous call.

So you can track the file version we are using here is the header from the library file:

/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************

* File Name : 91x_emi.c

* Author : MCD Application Team

* Version : V2.0

* Date : 12/07/2007

* Description : This file provides all the EMI firmware functions.

********************************************************************************

and

/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************

* File Name : 91x_emi.h

* Author : MCD Application Team

* Version : V2.0

* Date : 12/07/2007

* Description : This file contains all the functions prototypes for the

* EMI firmware library.

********************************************************************************

norbertg
Associate II
Posted on May 17, 2011 at 09:54

Hi

you are right :D

recently I found a very strange behavior of EMI, when

EMI_InitTypeDef EMI_InitStruct;

was local external memory didn't work

but when it was global it worked fine :-?

I read your post and I know now

when its local content of the EMI_InitStruct->EMI_BurstModeWrite_TransferLength

field is unpredictable and when EMI_Init writes

EMI_Bankx->BCR &= EMI_BurstModeWrite_TL_Mask;

EMI_Bankx->BCR |= EMI_InitStruct->EMI_BurstModeWrite_TransferLength;

it corrupts all fields in BCR register

but when its global its zeroed and everything looks good

Thanks

Norbert