cancel
Showing results for 
Search instead for 
Did you mean: 

interference between IAP and user application

issa
Associate II
Posted on March 05, 2014 at 10:29

Hi,

I can't use the same timer in IAP code and user application code in the same time, even if I reset all registers and interrupts concerning this timer before jump to user application address. Note that I reallocated the vector table for the user application...

Thank you
7 REPLIES 7
chen
Associate II
Posted on March 05, 2014 at 15:08

Hi

''I can't use the same timer in IAP code and user application code in the same time''

When you say IAP - In Application Programming.

Do you mean that you have written your own bootloader?

''I reset all registers and interrupts concerning this timer before jump to user application ''

In general - it is a good idea to disable and re-configure all peripherals to be used in each application during startup.

In the case of the timer - the timer must be disabled first before some of its registers can be changed (or the change take effect).

Posted on March 05, 2014 at 15:58

Ok, should we guess what part you're using, and the code you constructed that is failing?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
issa
Associate II
Posted on March 06, 2014 at 07:24

Hi again,

Thank you for your replies,

Yes it's my own bootloader. I am using STM32F105, and this is the way I reset all timer registers and the USB peripheral before jumping to the main application...

if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000){ 

/* Reset all registers used in System file */  

     NVIC_DisableIRQ(TIM3_IRQn);

     RCC->APB1ENR &=~RCC_APB1ENR_TIM3EN; 

     TIM3->CR1 = 0;                                          // reset command register 1

     TIM3->CR2 = 0;                                          // reset command register 2

     TIM3->PSC = 0;

     TIM3->ARR = 0;

     TIM3->DIER =0;                               // disable interrupt

     TIM3->CNT=0;

     TIM3->SR=0;

/* Disable the USB clock */

     RCC_APB1PeriphClockCmd((uint32_t)0x00800000, DISABLE);

     OTGD_FS_Handle_UsbReset_ISR();

     PowerOff();

     

 /* Jump to user application */

     JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);

     Jump_To_Application = (pFunction) JumpAddress;

 /* Initialize user application's Stack Pointer */

     __set_MSP(*(__IO uint32_t*) ApplicationAddress);

     Jump_To_Application();

    }

Note the USB causes the same problem, it seems it still working and when I plug in a USB cable, the main application crushes and after 3 resets the bootloader works again automatically ...

thank you

Posted on March 06, 2014 at 07:40

You might want to try programming the TIM3 registers BEFORE disabling the clock to the peripheral, as the writes definitely won't work after the clock is stopped.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
issa
Associate II
Posted on March 06, 2014 at 08:25

Thank you cliv1, you are right about Timer3... can you help me about how to disable correctly the USB??

chen
Associate II
Posted on March 06, 2014 at 10:32

Hi

I found the USB stack from the USB OTG does re-initialise OK.

The issue is to do with disconnection - you will need to force a software disconnect.

Depending on your processor, something like

    // force a USB soft disconnect

    // USB_OTG_dev.regs.DREGS->DCTL |= 0x02;

issa
Associate II
Posted on March 06, 2014 at 10:52

Thank you sung.chen_chung, that is what I did and it solved my problem ...