cancel
Showing results for 
Search instead for 
Did you mean: 

EMI usage

mark8
Associate II
Posted on October 25, 2006 at 07:01

EMI usage

10 REPLIES 10
mark8
Associate II
Posted on May 17, 2011 at 09:32

Hi:

Am having trouble getting the EMI (Bank0) to work. All I am getting is an error when I try to read or write to the bank.

My write is *((unsigned char*)0x3C000000)

I have tried setting up the EMI by hand (i.e. following the manual) and also used the CAPS tool and 91x_caps.h. Neither work and give me the same error.

I am using IAR Kickstart with J-Link.

Any samples or help that would be great.

Thanks

Mark

Posted on May 17, 2011 at 09:32

Have you enabled the CS0 pin ?

pay attention to the WAIT states of RD & WR.

I use 16 bit data bus and CS3 but the code works also with CS0 :)

#define _EMI_Bank3 // Bank3 is selected

#define _EMI_Bank3_RD_WS 0x08 // read wait state

#define _EMI_Bank3_OE_WS 0x02 // output enable assertion delay

#define _EMI_Bank3_WR_WS 0x08 // write wait state

#define _EMI_Bank3_WEN_WS 0x2 // write enable assertion delay

#define _EMI_Bank3_IDCY 0x04 // bus turnaround cycle

#define _CS // Chip select enabled

// GPIO CONFIG....

//

EMI_InitTypeDef EMI_InitStruct;

EMI_DeInit();

EMI_StructInit(&EMI_InitStruct);

SCU_AHBPeriphDebugConfig(__EMI_MEM_CLK, ENABLE);

GPIO_EMIConfig(ENABLE);

SCU_EMIModeConfig(_EMI_Mode);

SCU_EMIALEConfig(_EMI_ALE_Length, _EMI_ALE_Polarity);

SCU_EMIBCLKDivisorConfig(_EMI_CLK_Divisor);

EMI_InitStruct.EMI_Bank_IDCY = _EMI_Bank3_IDCY;

EMI_InitStruct.EMI_Bank_WSTRD = _EMI_Bank3_RD_WS;

EMI_InitStruct.EMI_Bank_WSTWR = _EMI_Bank3_WR_WS;

EMI_InitStruct.EMI_Bank_WSTROEN= _EMI_Bank3_OE_WS;

EMI_InitStruct.EMI_Bank_WSTWEN= _EMI_Bank3_WEN_WS;

EMI_InitStruct.EMI_Bank_MemWidth= _EMI_Bank_MemWidth;

EMI_Init (EMI_Bank3,&EMI_InitStruct);

mark8
Associate II
Posted on May 17, 2011 at 09:32

Thanks...but no luck. I had the CS line setup and also tried with your code (albeit in byte demux bus). What is happening is not that the bus is not being read but that my debug session is stopped when I try and work with external. See below....

i = *((unsigned int *)0x740000E0);

i = *((unsigned int *)0x3C0000E0);

I can step/run over the first line (to an EMI setup) but if I do the second one to Bank0 then I get trapped into ''Exception vectors'' in 91x_vect.c

I just think there must be something else to do with setup? Seems like there is a config missing to permit debug mode with EMI or something like that. Do I have to change the XCL?

Quite honestly I do not see why an example is not provided by ST.

Posted on May 17, 2011 at 09:32

hi:

I found a lot of problems with DEBUG enabled.

I'm working with DEBUG directive disabled.

I had the same problems in the past.

another think: if you use the buffered address

I think you have to enable the buffered mode

with IAR compiler see the 91x_init.s file.

mark8
Associate II
Posted on May 17, 2011 at 09:32

thanks...it does seem to be something like 'it just does not like debug mode' as I lose the clock and end up with all my stacks full and the PC reset to 0x00000000.

I have made a board mod (to implement RD as GPIO) and am running the bus in GPIO mode instead of EMI mode to work around this problem. I will look at it in more detail later.

hd2
Associate II
Posted on May 17, 2011 at 09:32

I'm having the same problem. If you figure out anything please post it. I'll do the same. My code/setup is practically identical to yours, so it must be something not obvious.

sjo
Associate II
Posted on May 17, 2011 at 09:32

What version of the str9 libs are you using ?

SCU_EMIModeConfig(_EMI_Mode); is not valid in v1.1 of the libs.

This is my setup for 16bit data 24bit adr multiplexed:

I have not had any problems with debug flag.

/* GPIO Setup */

SCU_APBPeriphClockConfig( __GPIO0, ENABLE );

SCU_APBPeriphClockConfig( __GPIO7, ENABLE );

SCU_APBPeriphClockConfig( __GPIO8, ENABLE );

SCU_APBPeriphClockConfig( __GPIO9, ENABLE );

GPIO_DeInit( GPIO0 );

GPIO_StructInit( &GPIO_InitStruct );

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;

GPIO_InitStruct.GPIO_Direction = GPIO_PinOutput;

GPIO_InitStruct.GPIO_Type = GPIO_Type_PushPull;

GPIO_InitStruct.GPIO_Alternate = GPIO_OutputAlt2;

GPIO_Init( GPIO0, &GPIO_InitStruct );

GPIO_DeInit( GPIO7 );

GPIO_StructInit( &GPIO_InitStruct );

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_All & (~GPIO_Pin_7);

GPIO_InitStruct.GPIO_Direction = GPIO_PinOutput;

GPIO_InitStruct.GPIO_Type = GPIO_Type_PushPull;

GPIO_InitStruct.GPIO_Alternate = GPIO_OutputAlt2;

GPIO_Init( GPIO7, &GPIO_InitStruct );

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;

GPIO_InitStruct.GPIO_Alternate = GPIO_OutputAlt3;

GPIO_Init( GPIO7, &GPIO_InitStruct );

SCU_AHBPeriphClockConfig( __EMI, ENABLE );

SCU_EMIModeConfig( SCU_EMI_MUX );

SCU_EMIALEConfig( SCU_EMIALE_LEN1, SCU_EMIALE_POLHigh );

GPIO_EMIConfig( ENABLE );

/* Enable EMI clock */

EMI_DeInit();

EMI_StructInit( &EMI_InitStruct );

EMI_InitStruct.EMI_Bank_MemWidth = EMI_Width_HalfWord;

EMI_Init( EMI_Bank0, &EMI_InitStruct );

It would be really good if ST posted a sample application, it took me quite a while to get this emi bus going !!

Cheers

Spencer Oliver

Anglia

hd2
Associate II
Posted on May 17, 2011 at 09:32

Turns out I had a clock gating gotcha. If you're having problems with debugging and EMI (processor losing clock) make sure you have the following.

One must enable both __EMI and __EMI_MEM_CLK in the clock gating control 0 register.

SCU_AHBPeriphClockConfig( __EMI | __EMI_MEM_CLK, ENABLE );

Apparently the EMI works as long as you don't debug even with the clock turned off. Go figure.

kais
Associate II
Posted on May 17, 2011 at 09:32

Hello all,

Please find here attached an STR9 project aims to write some bytes in EMI bus. It can be useful for you (as template) to configure the EMI relating to your needs. Note: both mode (Buffering & unbuffering mode are working fine for me.

Best regards,

Eris