cancel
Showing results for 
Search instead for 
Did you mean: 

VM problem

sbencke1
Associate II
Posted on January 11, 2004 at 07:42

VM problem

6 REPLIES 6
sbencke1
Associate II
Posted on May 17, 2011 at 11:57

1. Using PSDsoft Express I put the main flash in the Data space and Flash 2 in the Code space (VM = 0X92).

2. In my program I change VM to 0x8C.

Why when I reset my device the VM come back to 0x92 ? Where

PSDsoft write it ?

Please, somebody can kindly help me ? I would like to start a new application on main flash.

joseph2399
Associate II
Posted on May 17, 2011 at 11:57

When you initially configured you uPSD device using the PSDsoft Express, the software will have a default Reset value for the VM register depending on how you configured your device, this default value can subsequently be changed by MCU at run-time. However when you issue a Reset again, you should get the default Reset value again for the VM register.

sbencke1
Associate II
Posted on May 17, 2011 at 11:57

There is a way to change this reset value for the VM register at run time?

When I switch form one flash to other I don't know where is the adress of my code and how is my stack. I would like to cause a reset, using watchdog, and them my processor start in the beginning of the other flash.

Is it possible ?

joseph2399
Associate II
Posted on May 17, 2011 at 11:57

Yes, you should be able to load the desired VM value at the Reset Interrupt Service Routine. Or you can just configure your device with the desired setup using PSDexpress, please see the attached picture.

The answer to your question on if it is possible to setup uPSD to boot from the other flash after a reset is yes, please see the attached IAP code example.
sbencke1
Associate II
Posted on May 17, 2011 at 11:57

Moderator,

Let me try to explain better what I’m doing (I’m using uPSD3212):

1.In the PSDsoft I configure Main PSD flash as Data and Second PSD flash as Program;

2.My memory map:

fs0 = 0~3FFF à PAG 0

fs1 = 4000~7FFF à PAG 0

fs2 = 8000~BFFF à PAG 0

fs3 = C000~FFFF à PAG 0

csboot0 = 0~1FFF

csboot1 = 2000~3FFF

3.In “Merge MCU/DCP Firmware with PSD� option a put Program_2 in the FS0 and Program_1 in the csboot0;

Program 1:

void main(void) {

[Initialize peripherals and variables]

printfLCD(''Start on Flash-2\n''); //1a message

delay_ms(100);

PSD8xx_reg.PAGE = 0;

PSD8xx_reg.VM = 0x8C; // Here the program

//should jump to FLASH 1

Vm= PSD8xx_reg.VM;

Page = PSD8xx_reg.PAGE;

printfLCD(''I'm on Flash-2\n''); //2a message printfLCD(''Page= %x VM= %x\n'',Page,Vm; //3a message

delay_ms(100);

while (1) // Main demo loop

{ }

} // End main

Program 2:

void main(void) {

[Initialize peripherals and variables]

printfLCD(''Start on Flash-1\n'');//4a message

delay_ms(100);

PSD8xx_reg.PAGE = 0;

PSD8xx_reg.VM = 0x92; // Here the program should jump

// to FLASH 2

Vm= PSD8xx_reg.VM;

Page = PSD8xx_reg.PAGE;

printfLCD(''I'm on Flash-1\n''); //5a message

printfLCD(''Page= %x VM= %x\n'',Page,Vm);//6a message

delay_ms(100);

while (1) // Main demo loop

{ }

} // End main

The program 1 start ok , show the 1a message and after I execute the command “PSD8xx_reg.VM = 0x8C;� I have on my LCD the 5a message from program 2. I can jump from one flash to the other, but I can come back to the beginning of the program (Do you understand me ?).

When I force a reset, the VM register come back to the value that I programmed using PSDsoft and not to the value that a set with the command “PSD8xx_reg.VM = 0x8C;�. How can I change it definitely? How can I come back to the begging of my program after switching?

Thanks a lot

danielh1
Associate II
Posted on May 17, 2011 at 11:57

You like complications! but let me try a suggestion:

Every time you change the VM, keep a copy of it in the external RAM.

More precisely, you should have more than one copy, and a checksum.

The startup code of both programs will check this value and load it into the VM. If the checksum doesn't fit (power up situation), you a load a default value of your choice.

Bye, Daniel