Hi everyone,
I try to import project which was written in IAR to Sourcery G++. It worked there but now it doesn't. I still have problems with libaries but I think that I've added already all.
Now i've got problem like this:
**** Build of configuration Debug for project OBS_2010 ****cs-make all 'Building file: ../startup_ewarm.c''Invoking: Sourcery G++ C Compiler'arm-stellaris-eabi-gcc -O0 -g3 -Wall -c -fmessage-length=0 -fcommon -MMD -MP -MF"startup_ewarm.d" -MT"startup_ewarm.d" -mcpu=cortex-m3 -mthumb -o"startup_ewarm.o" "../startup_ewarm.c"../startup_ewarm.c:31: warning: ignoring #pragma language ../startup_ewarm.c:64: error: stray '@' in program../startup_ewarm.c:64: error: expected '=', ',', ';', 'asm' or '__attribute__' before string constant../startup_ewarm.c:86: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'const'../startup_ewarm.c:86: error: stray '@' in programcs-make: *** [startup_ewarm.o] Error 1
line 64: static unsigned long pulStack[256] @ ".noinit";
line 86:
_root const uVectorEntry __vector_table[] @ ".intvec" ={ { .ulPtr = (unsigned long)pulStack + sizeof(pulStack) }, // The initial stack pointer __iar_program_start, // The reset handler NmiSR, // The NMI handler FaultISR, // The hard fault handler IntDefaultHandler, // The MPU fault handler IntDefaultHandler, // The bus fault handler IntDefaultHandler, // The usage fault handler 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved IntDefaultHandler, // SVCall handler IntDefaultHandler, // Debug monitor handler 0, // Reserved IntDefaultHandler, // The PendSV handler SysTickHandler, // The SysTick handler IntDefaultHandler, // GPIO Port A IntDefaultHandler, // GPIO Port B IntDefaultHandler, // GPIO Port C IntDefaultHandler, // GPIO Port D IntDefaultHandler, // GPIO Port E UARTStdioIntHandler, // UART0 Rx and Tx IntDefaultHandler, // UART1 Rx and Tx IntDefaultHandler, // SSI0 Rx and Tx IntDefaultHandler, // I2C0 Master and Slave IntDefaultHandler, // PWM Fault IntDefaultHandler, // PWM Generator 0 IntDefaultHandler, // PWM Generator 1 IntDefaultHandler, // PWM Generator 2 IntDefaultHandler, // Quadrature Encoder 0 IntDefaultHandler, // ADC Sequence 0 IntDefaultHandler, // ADC Sequence 1 IntDefaultHandler, // ADC Sequence 2 TouchScreenIntHandler, // ADC Sequence 3 IntDefaultHandler, // Watchdog timer IntDefaultHandler, // Timer 0 subtimer A IntDefaultHandler, // Timer 0 subtimer B IntDefaultHandler, // Timer 1 subtimer A IntDefaultHandler, // Timer 1 subtimer B IntDefaultHandler, // Timer 2 subtimer A IntDefaultHandler, // Timer 2 subtimer B IntDefaultHandler, // Analog Comparator 0 IntDefaultHandler, // Analog Comparator 1 IntDefaultHandler, // Analog Comparator 2 IntDefaultHandler, // System Control (PLL, OSC, BO) IntDefaultHandler, // FLASH Control IntDefaultHandler, // GPIO Port F IntDefaultHandler, // GPIO Port G IntDefaultHandler, // GPIO Port H IntDefaultHandler, // UART2 Rx and Tx IntDefaultHandler, // SSI1 Rx and Tx IntDefaultHandler, // Timer 3 subtimer A IntDefaultHandler, // Timer 3 subtimer B IntDefaultHandler, // I2C1 Master and Slave IntDefaultHandler, // Quadrature Encoder 1 IntDefaultHandler, // CAN0 IntDefaultHandler, // CAN1 IntDefaultHandler, // CAN2 IntDefaultHandler, // Ethernet IntDefaultHandler, // Hibernate IntDefaultHandler, // USB0 IntDefaultHandler, // PWM Generator 3 IntDefaultHandler, // uDMA Software Transfer IntDefaultHandler, // uDMA Error IntDefaultHandler, // ADC1 Sequence 0 IntDefaultHandler, // ADC1 Sequence 1 IntDefaultHandler, // ADC1 Sequence 2 IntDefaultHandler, // ADC1 Sequence 3 IntDefaultHandler, // I2S0 IntDefaultHandler, // External Bus Interface 0 IntDefaultHandler // GPIO Port J};
Any ideas what is wrong? I try to solve this problem but can't figure out what is wrong.
Regards.
Tomasz
All compilers provide some proprietary extensions to the standard 'C' language, and this is especially true of embedded compilers.
Also, the 'C' standard itself states that many things are implementation-defined.
Therefore you cannot simply take code written specifically for one compiler (eg, IAR) and assume that it will "just work" on another (eg, GCC).
You need to port the code from being IAR-specific to being acceptable to GCC; this means:
So I guess that now I should look for some informations about what from IAR I can import and what I can't. Because unfortunetly I don't know.
Maybe you know where can I find such as informations?
Tomasz RogalskiMaybe you know where can I find such as informations?
Yes, it will be in the Manuals for each compiler.
Most compilers have a "Strict ANSI" option to disable their proprietary extensions. Assuming IAR has it, you could try building the code using IAR with this option enabled - this will identify all the IAR proprietary extensions for you.
You will then have to study the IAR Manuals to determine what each extension does.
You will then have to study the GCC Manuals to determine how to achieve the same effect in GCC.
Similarly, you will have to check both sets Manuals for their Implementation-Defined behaviours...
All right, so if I compiled file in IAR with option strict ISO/ANSI on and it is done without any errors that means that file is all right and I should look somwhere else to find solution of my problems. Am I right? Maybe the problem is that still some files are missing.
By the way thank you for your help Andy.
Tomasz Rogalskiif I compiled file in IAR with option strict ISO/ANSI on and it is done without any errors that means that file is all right
If that were the case, then, yes - that should be true.
But it clearly cannot be the case!
From the code you originally posted:
Tomasz Rogalskiline 64: static unsigned long pulStack[256] @ ".noinit"; line 86: _root const uVectorEntry __vector_table[] @ ".intvec" ={ { .ulPtr = (unsigned long)pulStack + sizeof(pulStack) },
_root const uVectorEntry __vector_table[] @ ".intvec" ={ { .ulPtr = (unsigned long)pulStack + sizeof(pulStack) },
The red highlighted items are clearly not standard ANSI 'C' - are they?!
And those were the things that GCC was complaining about, weren't they?
Tomasz RogalskiMaybe the problem is that still some files are missing
No, that does not follow at all from the error messages that you posted.
The error messages that you posted most definitely are to do with syntax errors in the files that you do have!
If the problems were due to missing files, you would be getting Linker erors - not Compiler errors.
I will not start another topic because I think that I will have much more problems.
I try to set some bits in registers and I have got error like this:
error: lvalue required as left operand of assignment
Line looks like that:
SYSCTL_RCGC1_SSI0=1;
I know that is simple error but I am really beginner and now I have got a lot problems.
Regards
SYSCTL_RCGC1_SSI0 is not a register. It is a constant definition of a bit field value in a register. If you wanted to set the bit in the register, you would do something more like: HWREG(SYSCTL_RCGC1) = HWREG(SYSCTL_RCGC1) | SYSCTL_RCGC1_SSI0; if you wanted to clear the bit, you would do something like:
SYSCTL_RCGC1_SSI0 is not a register. It is a constant definition of a bit field value in a register.
If you wanted to set the bit in the register, you would do something more like:
HWREG(SYSCTL_RCGC1) = HWREG(SYSCTL_RCGC1) | SYSCTL_RCGC1_SSI0;
if you wanted to clear the bit, you would do something like:
HWREG(SYSCTL_RCGC1) = HWREG(SYSCTL_RCGC1) & ~SYSCTL_RCGC1_SSI0;
But more likely, what you really want to do is call the SysCtlPeripheralEnable() or SysCtlPeripheralDisable() function for the peripheral you want to enable or disable. In this case it would be:
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
OK, thank you very much.
To sum up:
If I have got in documentation that I should set some bit:
to enable:
to disable:
SysCtlPeripheralDisable(SYSCTL_PERIPH_SSI0);
to clear register just disable?
To set any value to register ?
And the:
What does it mean to write register?
Thank for your help.
Tomasz RogalskiWhat does it mean to write register?
Writing a register (or memory location) means to send data to it;
Reading means to get data from it.
OK, and how to set value 0x00000000 to register SSI_CR1?
SSI_CR1|=0x00000000; <= doesn't work
The name of register is SSI_0_CR1 but compiler says that:
'SSI_O_CR1' undeclared (first use in this function)
Tomasz RogalskiSSI_CR1 |= 0x00000000; <= doesn't work
Even if this compiled without error, it would not set the register to zero!
I think you need to look again at the meaning of the |= operator in the 'C' programming language.
Keil provide a useful book list - they are not all Keil-specific: http://www.keil.com/books/
For an online 'C' textbook, see: http://publications.gbdirect.co.uk/c_book/
Thank you Andy, I've read some about setting bites, registers etc.
Now, when I compile my project I've got error like this:
unrecognised emulation mode: cpu=cortex-m3Supported emulations: armelf
Should I change emulation mode? Is it possible? In settings?