Need a support for IAR-STM8

Thread Starter

STP.Asghari

Joined Nov 22, 2022
12
Hi everyone
I have downloaded a code and I want to use it in IAR for stm8 software.
Code:
// delay v1.0
// delays are limited by F_CPU * x overflowing 32bit integer value
#ifndef _UTIL_DELAY_H_
#define _UTIL_DELAY_H_ 1

#ifndef F_CPU
#warning F_CPU is not defined!
#endif

/*
 * Func delayed N cycles, where N = 3 + ( ticks * 3 )
 * so, ticks = ( N - 3 ) / 3, minimum delay is 6 CLK
 * when tick = 1, because 0 equels 65535
 */

static @inline void _delay_cycl( unsigned short __ticks )
{
#if defined(__CSMC__)
/* COSMIC */
  //#define T_COUNT(x) (( F_CPU * x / 1000000UL )-3)/3) // pùvodní varianta byla pøesnìjší ale hrozila podtíkáním
    #define T_COUNT(x) (((( F_CPU * x / 1000000UL ))/3)+1)
    // ldw X, __ticks ; insert automaticaly
    _asm("nop\n $N:\n decw X\n jrne $L\n nop\n ", __ticks);
#elif defined(__SDCC)
  //#define T_COUNT(x) (( F_CPU * x / 1000000UL )-5)/5) // pùvodní varianta byla pøesnìjší ale hrozila podtíkáním
    #define T_COUNT(x) (((( F_CPU * x / 1000000UL ))/5)+1)
    __asm__("nop\n nop\n");
    do {         // ASM: ldw X, #tick; lab$: decw X; tnzw X; jrne lab$
                __ticks--;//      2c;                 1c;     2c    ; 1/2c 
        } while ( __ticks );
    __asm__("nop\n");
#elif defined(__RCST7__)
/* RAISONANCE */
  #error ToDo for RAISONANCE
#elif defined(__ICCSTM8__)
/* IAR */
  #error ToDo for IAR
#else
 #error Unsupported Compiler!          /* Compiler defines not found */
#endif
}
This error occurs during compilation:
Code:
Fatal Error[Pe035]: #error directive: ToDo for IAR L:\شرکت\پروژه ها\Gps\Code\6 - rah andazi lcd\8\delay.h 37
The error is related to the following line:
Code:
  #error ToDo for IAR

I would be grateful if the experts of this forum could help to solve this problem.
 

MrChips

Joined Oct 2, 2009
30,823
What is written is straight forward.
Someone has written a delay function for different compilers.
Only CSMC and SDCC are supported. IAR is unfinished.

__ICCSTM8__ is declared somewhere else.

Replace line 37 with the delay implementation:
Code:
while (__ticks--);
 
Top