cancel
Showing results for 
Search instead for 
Did you mean: 

STR75x: Jump to Execute Code from SMI

alessandro2399
Associate II
Posted on December 06, 2007 at 07:58

STR75x: Jump to Execute Code from SMI

1 REPLY 1
alessandro2399
Associate II
Posted on December 06, 2007 at 07:58

I developed my main application and I loaded it in the STR75x embedded flash.

My application is compiled with interwork code option enabled to mix ARM and Thumb code.

My application uses two M25P64 on SMI bank0 and bank1 to load/store data.

Now I have developed another application, compiled in ARM mode only and loaded in the first sector of the M25P64 memory on bank0 (0x80000000 - 0x80010000), that can be executed at startup in SMI boot mode AND can be launched and executed from the first main application (with no return).

This last application runs and works properly when the board starts in SMI boot mode, but when it is launched from the main application it stops working in a few secons.

In order to launch the SMI application my main application execute this function:

__arm __interwork void Jump2SMICode( void )

{

SMI_InitTypeDef SMI_InitStructure;

ErrorStatus OSC4MStartUpStatus;

void (*pSMICode)( void ) = (void (*)(void))0x80000000L; // SMI code start address

/* Deinitializes all the peripheral registers */

__disable_interrupt();

MRCC_DeInit();

EIC_DeInit();

EXTIT_DeInit();

GPIO_DeInit( GPIO0 );

GPIO_DeInit( GPIO1 );

GPIO_DeInit( GPIO2 );

I2C_DeInit();

PWM_DeInit();

RTC_DeInit();

SMI_DeInit();

SSP_DeInit( SSP0 );

SSP_DeInit( SSP1 );

TB_DeInit();

TIM_DeInit(TIM0);

TIM_DeInit(TIM1);

TIM_DeInit(TIM2);

UART_DeInit(UART0);

UART_DeInit(UART1);

UART_DeInit(UART2);

WDG_DeInit();

FLASH_DeInit();

// configure SMI ------------------------------------

/* SMI clock configuration */

SMI_InitStructure.SMI_ClockHold = 0;

SMI_InitStructure.SMI_Prescaler = 1;

SMI_InitStructure.SMI_DeselectTime = 1;

SMI_Init(&SMI_InitStructure);

/* Enable SMI Alternate Functions */

GPIO_PinRemapConfig(GPIO_Remap_SMI_EN, ENABLE);

/* Enable Bank 0 */

SMI_BankCmd(SMI_Bank_0, ENABLE);

/* Select Bank 0 */

SMI_SelectBank(SMI_Bank_0);

/* Enable SMI Flash Fast Read mode */

SMI_FastReadConfig(SMI_FastRead_Enable);

// configure MRCC ------------------------------------

/* Wait for OSC4M start-up */

OSC4MStartUpStatus = MRCC_WaitForOSC4MStartUp();

if(OSC4MStartUpStatus == SUCCESS)

{

/* Set HCLK to CKSYS */

MRCC_HCLKConfig(MRCC_CKSYS_Div1);

/* Set CKTIM to HCLK/2 */

MRCC_CKTIMConfig(MRCC_HCLK_Div2);

/* Set PCLK to CKTIM */

MRCC_PCLKConfig(MRCC_CKTIM_Div1);

/* FLASH in burst mode */

CFG_FLASHBurstConfig(CFG_FLASHBurst_Enable);

/* Set CKSYS to 48MHz */

MRCC_CKSYSConfig(MRCC_CKSYS_OSC4MPLL, MRCC_PLL_Mul_12);

}

/* GPIO pins optimized for 3V3 operation */

MRCC_IOVoltageRangeConfig(MRCC_IOVoltageRange_3V3);

/* Enable GPIOs clocks */

MRCC_PeripheralClockConfig(MRCC_Peripheral_GPIO, ENABLE);

// start executing code from SMI -------------

pSMICode();

/* we will never return here */

}

This function seems to work well, because I see the SMI application starts correctly, initializing all the external peripherals, writing the first text and bitmap on a graphic LCD, but then stops as it was blocked. Is this function correct to jump executing SMI code?

Also I note from a led of may board that the Time Base interrupt handler of the main application is still active: how is it possible?