Author Topic: STM8S103F3 IAR Error  (Read 6391 times)

0 Members and 1 Guest are viewing this topic.

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
STM8S103F3 IAR Error
« on: May 27, 2016, 10:19:33 am »
Hello all,

I've just installed the 8k limited version of IAR for STM8 controllers and I'm testing it with the stm8s103f3P6.

When testing the interrupts I've included the "iostm8s103f3.h" header and started having the following error:

Code: [Select]
Error[Pe018]: expected a ")" C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.3\stm8\inc\iostm8s103f3.h 1164

inspecting the header file I see that the error is being generated by the OPT bit in the following structure:

Code: [Select]
/* Flash control register 2 */
#ifdef __IAR_SYSTEMS_ICC__
typedef struct
{
  unsigned char PRG         : 1;
  unsigned char             : 3;
  unsigned char FPRG        : 1;
  unsigned char ERASE       : 1;
  unsigned char WPRG        : 1;
  unsigned char OPT         : 1;
} __BITS_FLASH_CR2;
#endif
__IO_REG8_BIT(FLASH_CR2,   0x505B, __READ_WRITE, __BITS_FLASH_CR2);

If I change the OPT bit name for OOPT for example the error disappears and everything is ok.

Does someone know why does this happens?

Thanks in advanced,
best regards, Mauro.
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
Re: STM8S103F3 IAR Error
« Reply #1 on: May 27, 2016, 10:24:39 am »
Do you have other header files before this one that might have defined OPT?
// richard http://imagecraft.com/
JumpStart C++ for Cortex (compiler/IDE/debugger): the fastest easiest way to get productive on Cortex-M.
Smart.IO: phone App for embedded systems with no app or wireless coding
 
The following users thanked this post: maurosmartins

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
Re: STM8S103F3 IAR Error
« Reply #2 on: May 27, 2016, 10:33:39 am »
Hello richardman, thank you for your reply.

my code is just a sample code from STM8S StdPeriph Examples (GPIO) it includes stm8s.h and after the iostm8s103f3.h.

after your post I've checked the stm8s.h and it declares OPT as follows:

Code: [Select]
#define OPT ((OPT_TypeDef *) OPT_BaseAddress)

You are right, I can't test it now but this should be the cause.

I take the opportunity to ask do I need to include stm8s.h to use the standard peripheral libraries? what would a valid project configuration be?

Thanks, Mauro.
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
Re: STM8S103F3 IAR Error
« Reply #3 on: May 27, 2016, 10:44:52 am »
No idea, I am just a compiler writer so I see this sort of problem all the times from users :-)
// richard http://imagecraft.com/
JumpStart C++ for Cortex (compiler/IDE/debugger): the fastest easiest way to get productive on Cortex-M.
Smart.IO: phone App for embedded systems with no app or wireless coding
 

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
Re: STM8S103F3 IAR Error
« Reply #4 on: May 27, 2016, 10:46:41 am »
Hello, richardman

nevertheless thank you for your comment, it helped me a lot understanding what is wrong!

Best regards, Mauro.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM8S103F3 IAR Error
« Reply #5 on: May 27, 2016, 03:06:54 pm »
I'm not convinced that that's the problem.

You certainly can have a variable and an element of a struct to share the same name. Nothing wrong with that.

Something else is at fault here, I think.
================================
https://dannyelectronics.wordpress.com/
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
Re: STM8S103F3 IAR Error
« Reply #6 on: May 27, 2016, 05:13:12 pm »
I'm not convinced that that's the problem.

You certainly can have a variable and an element of a struct to share the same name. Nothing wrong with that.

Something else is at fault here, I think.

Nope :-) If you look at the #define he finds, when expanded, it creates a bad C code in the original code snippet  >:D
// richard http://imagecraft.com/
JumpStart C++ for Cortex (compiler/IDE/debugger): the fastest easiest way to get productive on Cortex-M.
Smart.IO: phone App for embedded systems with no app or wireless coding
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM8S103F3 IAR Error
« Reply #7 on: May 27, 2016, 06:31:48 pm »
Quote
do I need to include stm8s.h to use the standard peripheral libraries?

Yes.

Quote
what would a valid project configuration be?

The specifics are slight different but at a minimal, you will need to select the right chip, define USE_STDPERIPH_DRIVER, and define the chip name. You may also need to define the (external) oscillator frequency if used - there is a bug in the STD driver on that front -> that portion of the std lib is definitely coded by an intern, :)

Obviously, set the include path as well.

I tried the following on 1.1x, 1.2x, 1.3x, and 1.4x - the only thing I didn't try is the 2.2x. they all compiled flawlessly.

Code: [Select]
#include <iostm8s103f3.h>

unsigned char OPT=0;

typedef struct
{
  unsigned char PRG         : 1;
  unsigned char             : 3;
  unsigned char FPRG        : 1;
  unsigned char ERASE       : 1;
  unsigned char WPRG        : 1;
  unsigned char OPT         : 1;
} __myBITS_FLASH_CR2;

__IO_REG8_BIT(myFLASH_CR2,   0x505B, __READ_WRITE, __myBITS_FLASH_CR2);

int main( void ) {
  return 0;
}
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM8S103F3 IAR Error
« Reply #8 on: May 27, 2016, 06:46:27 pm »
I usually don't use the device specific header files. Even if I don't use the std periph lib, I still use stm8s.h for the struct-like register layout.

project configurations can be gleaned from the stm8s.h file.
================================
https://dannyelectronics.wordpress.com/
 

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
Re: STM8S103F3 IAR Error
« Reply #9 on: May 27, 2016, 10:55:03 pm »
Hello all, thank you for your replies!

dannyf, I have defined the microcontroller and USE_STDPERIPH_DRIVER as follows:


I've also removed the controller specific header. But, this way where can I check the interrupt vectors? do you write the vector directly?

Best regards, Mauro.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM8S103F3 IAR Error
« Reply #10 on: May 28, 2016, 02:05:11 am »
The right way is to read the compiler manual;

The wrong way is to read stm8s.h, towards the end.
================================
https://dannyelectronics.wordpress.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf