0

whenever I generate my code with STM32cubeMX on Iar embedded workbench V8.5 this error is still present

Fatal Error [Pe035]: #error directive: "Unknown target." 

enter image description here

AEM
  • 1,354
  • 8
  • 20
  • 30
Safwen
  • 5
  • 4
  • Please show the code relevant to this error. – shapiro yaacov May 06 '20 at 07:13
  • Have a look at the IAR project configuration and see which target is selected. – theSealion May 06 '20 at 10:04
  • This looks like a problem with how your ew-project is set up. Setting up a project from scratch is tedious I usually start with a working example-project for the development board I use and replace it bit-by-bit. – Johan May 06 '20 at 11:58
  • See in the image the tab "build log"? That is the unfiltered build log in plain-text. You should copy and paste that into your question rather then posting a picture of text. Moreover the "Build" tab is filtered and processed for presentation, but generally just hides useful information. In this case useful information has disappeared of the edge of the File column for example. – Clifford May 06 '20 at 15:13

1 Answers1

0

The error is unrelated to either downloading or debugging. It is a build error.

The #error is a pre-processor directive in the code. If you double-click on one of those errors it will no doubt take you to the offending code. It is not possible from the image to direct you to the exact cause (you should post the "build Log" text in its entirety, rather then an image of the "build" tab), but will no doubt be code similar to (elided):

#if defined(STM32F405xx)
  #include "stm32f405xx.h"
#elif defined(STM32F415xx)
  #include "stm32f415xx.h"
#elif 
    ...  
#elif defined(STM32F423xx)
  #include "stm32f423xx.h"
#else
 #error "Unknown Target"   <<<< HERE - no target macro has been defined.
#endif

The point being that the HAL code supports multiple STM32 variants and it is necessary to set a macro identifying your target so that the appropriate part specific code will be built.

If you created your project using STM32CubeMX or from the IAR IDE, there will be some place in the configuration where you can specify your target. (in the case of CubeMX I don't think you can do much of anything until you have selected the target). Failing that there will be some place to define command-line build macros in the build configuration.

Clifford
  • 88,407
  • 13
  • 85
  • 165