2016-11-19 10:17 PM
Hi,
I'm learning to code in assembly on stm32f103zet6 mcu with Atollic True Studio. I'm able to write a simple program and see the execution on debugger. However, I'm not able to locate the vector table (in disassembly window) that is written on flash memory. Here is my understanding of vector table. The vector table is the first thing that is written in flash. The very first word written is the initial value to be loaded in the stack pointer. The second word is the value to be loaded in PC. Now, if my flash memory starts at 0x08000000 address, I should be able to see the initial stack pointer value at address 0x08000000 - 0x08000003 (32 bits). And value of PC at address 0x08000004 - 0x08000007 which is usually the address of the Reset_Handler. But I'm not able to see those values in the disassembly window. Could anyone please explain if I'm looking in the right place or my understanding of vector table is flawed at this point? Thanks! Navin #vectortable #stm32f1032016-11-19 10:56 PM
But they are binary values, not assembler instructions. You should dump them as 32-bit values in the Memory View. The address will be odd and >0x08000000
Assuming the flash is selected for startup, then you should be able to view the memory at zero, and see the table.2016-11-19 11:35 PM
ok.. I'm not able to understand this now. Vector table is always stored at 0x0 address. But 0x0 is shadowed to flash memory. So 0x08000000 should contain the vector table. I know that flash memory addresses usually contain the opcodes. But here, shouldn't the starting addresses of flash contain the vector table values? I'm not able to understand this. Could you please explain or direct me to some link where it is explained adequately.
Thanks!2016-11-19 11:46 PM
You could review the Cortex-M3 TRM ?
What 32-bit words are you seeing? Flash can contain all manner of data, in all manner of forms.2016-11-20 12:00 AM
hey, I was able to see the vector table in the memory dump as you suggested. I've attached the screenshot. In the image, you can see both memory browser window and the disassembly window. Now, my concern is that how come the same address on flash memory contains two different data. If you look into the memory browser, the address 0x08000000 has value 0x20010000 which is the initial value of stack pointer for a 64K RAM. But, if you look into the disassembly window, the address 0x08000000 contains value 0x00000000 which I believe is some opcode. How is it possible that same address has different values? Also, which is the correct value that is actually physically written into that location on flash? Am I confusing between the disassembly and memory dump?
________________ Attachments : debug.PNG : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htjm&d=%2Fa%2F0X0000000aWM%2Fjw.cHR0Luq4h03AaGqLHRGtrisfpgOQSWRF3r9BIPtk&asPdf=false2016-11-20 07:19 AM
The disassembly view here shows 16-bit words as 8 hex digits, and byte swaps. It is showing you the same data, you are just not interpreting it properly and it is poorly presented.
The 32-bit memory view is more representative of what the processor sees in these locations.2016-11-20 08:13 AM
Yes, you are right. I see it now. I wonder why is it jumbled up in the disassembly. Anyways, thanks!