AnsweredAssumed Answered

STM8S003F3 using COSMIC C compiler - "invalid pointer initializer" in stm8_interrupt_vector.c

Question asked by R V on Jun 17, 2018
Latest reply on Jun 19, 2018 by luca

Hi,

I am trying to implement timer based on interrupt in STM8S003F3 using STVD and COSMIC C Compiler free version.

I tried following this tutorial available on web Starting STM8 Microcontrollers - Page 19 of 27 - Embedded Lab . However, while modifying the stm8_interrupt_vector.c file for adding my TIM2_IRQHandler in the interrupt vector struct under irq no. 13, I am getting this error: "invalid pointer initializer". What am I doing wrong here?

 

My stm8_interrupt_vector.c looks like this:

typedef void @far (*interrupt_handler_t)(void);

 

struct interrupt_vector {
    unsigned char interrupt_instruction;
    interrupt_handler_t interrupt_handler;
};

 

@far @interrupt_handler_t void NonHandledInterrupt (void)
{
    /* in order to detect unexpected events during development,
       it is recommended to set a breakpoint on the following instruction
    */
    return;
}

 

extern void _stext();     /* startup routine */

 


struct interrupt_vector const _vectab[] = {
    {0x82, (interrupt_handler_t)_stext}, /* reset */
    {0x82, NonHandledInterrupt}, /* trap  */
    {0x82, NonHandledInterrupt}, /* irq0  */
    {0x82, NonHandledInterrupt}, /* irq1  */
    {0x82, NonHandledInterrupt}, /* irq2  */
    {0x82, NonHandledInterrupt}, /* irq3  */
    {0x82, NonHandledInterrupt}, /* irq4  */
    {0x82, NonHandledInterrupt}, /* irq5  */
    {0x82, NonHandledInterrupt}, /* irq6  */
    {0x82, NonHandledInterrupt}, /* irq7  */
    {0x82, NonHandledInterrupt}, /* irq8  */
    {0x82, NonHandledInterrupt}, /* irq9  */
    {0x82, NonHandledInterrupt}, /* irq10 */
    {0x82, NonHandledInterrupt}, /* irq11 */
    {0x82, NonHandledInterrupt}, /* irq12 */
    //{0x82, NonHandledInterrupt}, /* irq13 */
    {0x82, (interrupt_handler_t)TIM2_UPD_IRQHandler}, /* irq13 */
    {0x82, NonHandledInterrupt}, /* irq14 */
    {0x82, NonHandledInterrupt}, /* irq15 */
    {0x82, NonHandledInterrupt}, /* irq16 */
    {0x82, NonHandledInterrupt}, /* irq17 */
    {0x82, NonHandledInterrupt}, /* irq18 */
    {0x82, NonHandledInterrupt}, /* irq19 */
    {0x82, NonHandledInterrupt}, /* irq20 */
    {0x82, NonHandledInterrupt}, /* irq21 */
    {0x82, NonHandledInterrupt}, /* irq22 */
    {0x82, NonHandledInterrupt}, /* irq23 */
    {0x82, NonHandledInterrupt}, /* irq24 */
    {0x82, NonHandledInterrupt}, /* irq25 */
    {0x82, NonHandledInterrupt}, /* irq26 */
    {0x82, NonHandledInterrupt}, /* irq27 */
    {0x82, NonHandledInterrupt}, /* irq28 */
    {0x82, NonHandledInterrupt}, /* irq29 */
};

and added this to stm8_itc.h

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM8S_ITC_H
#define __STM8S_ITC_H

@far @interrupt void TIM2_UPD_IRQHandler(void);

/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"

and this is my TIM2_UPD_IRQHandler(void) ISR inside stm8_itc.c:

extern char cFlag;      // char cFlag is declared in main.c and used in the interrupt as a flag to be used in while(1)

 

void TIM2_UPD_IRQHandler(void)
{
    TIM4_ClearITPendingBit(TIM2_IT_UPDATE);
    TIM4_ClearFlag(TIM2_FLAG_UPDATE);
    cFlag = 1;
}

What am I doing wrong here? Any suggestions would be of really great help. Thanks!

Outcomes