This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
The 'real' input editor apparently was offline for some reason ove rthe last hours. So you probably only got the plain input window (which does not allow any formatting unless you manually type HTML code in)
The original error you got was about the content of the reset vector being 4 bytes while th ereserved space is only 2 bytes.
This happens if for some reason teh function to which the reset vector points is placed into the flash above 64k. Yet all interrutp vectors (includign the reset vector) are jsut 16 bit and point to the lower 64k address space.
This means, your reset function, as well as any interrupt function have to begin in the lower 64k. In assembly language, it may consist of just a jump to the 'real'interrupt function anywhere in the whole flash (at the expense of some additional cycles execution time for the jump).
When using C, the compiler will automatically take care of this, placing all functions declared as interrupt into th elower text segment specifically. But when using assembly, you'll have to take care of this on your own.
For the debugger error, the debugger is configured to place an auto breakpoint onto the main function, as this is thestarting point of any C program. You don't have such a function in your project. So you'll need to define a symbol of this name at the starting location of your project.
Maybe you can configure the debugger to not 'stop at main' (maybe there is such an option in the project config), so the debugger will not as default try to locate main and stop there.
Thank You for reading through that as it was me and it all seemed like a jungle.
Jens-Michael Gross said:For the debugger error, the debugger is configured to place an auto breakpoint onto the main function, as this is thestarting point of any C program. You don't have such a function in your project. So you'll need to define a symbol of this name at the starting location of your project.
Maybe you can configure the debugger to not 'stop at main' (maybe there is such an option in the project config), so the debugger will not as default try to locate main and stop there.
Ok so, i think i found a similar 'solution' that went about defining a global symbol "main" ( .global _main) and substituting _main for the RESET symbol.
But first I think I need to tackle a more basic problem : what is a symbol?
My professor has never mentioned this. I believe it can be thought of as some sort of label... but this is just a rough grasp of numerous lines of code that I've read.
Also, I took a peed in the .map file and noticed the following:
address name
----------- -------
00000200 __text__
00000200 _main
00000200 edata
00000200 end
Is this relevant? From what i can gather the 'end' symbol is in the same place as my '_main' symbol. Since I don't know what exactly each are, I'm not sure, but it seems to me that they shouldn't have the same address at least...
Thanks Again
The other way round. A label is some sort of a symbol.Jose Taveras said:what is a symbol? [...]I believe it can be thought of as some sort of label.
A symbol has a name and a constant value, which is not necessarily known at compile time, but gets known at latest during the link stage. So a constant may be a symbol (if compiler/assembler can substitute the name by the value).
A variable is no symbol, hovever, the address of a variable is a symbol.
Or a label.
Symbols are substituted as soon as their value is known. In case of local labels or variables, the compiler/assembler does it. In this case the symbol is not forwarded to the next stage. Like the precompiler will substitute all texts that are identified as macros, so the compiler will only see the substituted text. If a symbol cannot be substituted because its final value is not known yet (or it never has been declared), the symbol is forwarded to the next pürocessing stage in the hope that it can be resolved there.
e.g. when calling a function without including the proper header file, the compiler will issue a warning about missing prototype, yet the program will still properly compile. The compile forwards the symbol to the linker and if the linker finds the proper function in any of the linked files, all is well. (the compiler, however, cannot ensure that the parameter lists match, hence the necessity of the warning)
Just declaring .global main generates a symbol that is located in the global address segment. It is not, however, connected to a specific location, just in front of what follows it (and there follows nothing), so the linker puts it to 0x200.
Defining a label is basically the same: it defines a symbol and connects its value to 'the final location of what follows', which is usually code. So its final value is the final location of the code after it.
Once the linker has collected and sorted all code/the variables, all labels should have get their final value and the linker can substitute them.
btw: using a symbol is implicitely declaring it, even if it is not defined anywhere. In this case, it is there but still undefined and you'll get a linker error. THis happens if you misspell a register name or function name, or forget to include the object file where it is actually defined.
Well, __text_ is assigned to the start of the flash 'text' segment where all code is placed. _main is part of this segment and put there (so same value). edata is the position of the initializer area for global variables and the end of the code part in the flash, and since there was no content before it, it still has the same value. And end, well, it is the flash location of the first byte after the last byte of your program. Since your program contains 0 bytes of code/init data, it still has the same value/points to the same address as the others.Jose Taveras said:Since I don't know what exactly each are, I'm not sure, but it seems to me that they shouldn't have the same address at least...
If you put a 'nop' instruction right behind your declaration of main, you'll likely see edata and end change to 202.
Ok. I intend to revisit this a couple of times as I seem to understand, but only after I can get this running and can actually start playing with it will I be able to verify anything that I've learned.
Right now I keep receiving no error, just a simple
MSP430: Can't Run Target CPU: Could not run device (to breakpoint)
And nothing else.
This is my code as of today:
.cdecls C,LIST,"msp430g2231.h" ; Include device header file
;-------------------------------------------------------------------------------
.text
; Progam Start
.global _main
;-------------------------------------------------------------------------------
_main mov.w #300h,SP ; Initialize 'x1121 stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
SetupP1 bis.b #001h,&P1DIR ; P1.0 output ;
Mainloop xor.b #001h,&P1OUT ; Toggle P1.0 Wait mov.w #050000,R15 ;
Delay to R15 L1 dec.w R15 ; Decrement R15
jnz L1 ;Delay over?
jmp Mainloop ; Again
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
.sect ".reset" ; MSP430 RESET Vector
.end
What does the map file say?
Does teh reset vector contain anything? You started a section '.reset:', but it does not contain any value. You have to place an address (or a symbol) there that points to the very beginning of your code. Which isn't necessaily main (on C programs it is the startup code that initializes the variables before jumping to main), but in your project it would be main.
I don't know th e assembler syntax for your assembler (I only worked with MSPGCC), but I think it has to be something like
.sect ".reset"
. dw _main // define a word value at this location
.end
If the reset vector isn't set, the processor does not know where to start, and the breakpoint in main is never hit. Hence the error.
that was a mistake on my part... the actual code goes:
.cdecls C,LIST, "msp430g2211.h" .global _main ;------------------------------------------------------------------------------ .text ; Progam Start ;------------------------------------------------------------------------------ _main mov.w #0280h,SP ; Initialize stackpointer StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT SetupP1 bis.b #001h,&P1DIR ; P1.0 output ; Mainloop xor.b #001h,&P1OUT ; Toggle P1.0 Wait mov.w #050000,R15 ; Delay to R15 L1 dec.w R15 ; Decrement R15 jnz L1 ; Delay over? jmp Mainloop ; Again ;
;------------------------------------------------------------------------------
; Interrupt Vectors ;------------------------------------------------------------------------------ .sect ".reset" ; MSP430 RESET Vector .short _main ; .end
I'm going to try and test the mcu in another computer. Since I've tested various example codes and keep getting the same error, I'm starting to think the actual code isn't the problem, but instead something pertaining to the CCS setup or installation. I tried reinstalling the software but keep getting the same error.
The most frustrating thing is that my first attempt at running a program was successful. I loaded a .c LED toggle program unto the MCU. It worked fine. But I tried reproducing the same test under the same conditions (fresh reinstall, fresh workspace) to receive the same frustrating error.
I have a feeling it's going to work at the University's lab but I'd like to be able play with this in the sanctity of my home computer.
I'll post results when I can later this weekend. Thanks again.
Hi, I'm facing the same problem as you encountered in your original post in trying to get this program to compile and thus get the leds to light up upon pressing the push button. I was wondering if you ever figured out how to make it work.
Thanks,
tjk
Hi,
I faced the same problem, my solution has erase the .end at the end of the code and compile the code like that. It worked just fine.
Afonso
Minor correction: you cannot 'compile' an assembly program. It is processed by the assembler, so it is 'assembled' :)Afonso Pereira Bernardino said:compile the code like that
I agree that his isn't helpful for the original problem.
Unfortunately, each assembler uses its own language and format specifics. And I never used IAR or CCS assembler.
However, it is possible that the system chokes on a missing line break after the .end or something like that.
**Attention** This is a public forum