cancel
Showing results for 
Search instead for 
Did you mean: 

Using Interrupts with Cosmic on STM8AF5288

BCowa
Associate II

Just changing over to the STM8 using STVD and Cosmic.

I have converted an existing project over to the new chip and compiler and have a clean compile of all the modules.

The Linker is complaining that

#error clnk Debug\5971.lkf:1 @svlreg missing for function f_CAN_RX_IRQHandler

I have updated the vector table in stm8_interrupt_vector.c to identify I have a Tim2 and a CAN Rx interrupts(see below). The Tim 2 interrupt handler is in a file called 5791.c and the CANRx interrupt is in the stm8s_it.c inserted in the list of interrupt handlers as shown below:

//****************************************************************************

// CAN_RX_IRQHandler

// Stores data into extern variables

// Calls CAN_RX() to parse data

//****************************************************************************

   INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8)

   {

      extern uint32_t CANMsgIde;

      extern uint8_t CANMsgDLC;

      extern uint8_t CANMsgData[8];

      uint8_t i;

      CAN_Receive();                                          // Get the message from the Rx FIFO

      CANMsgIde = CAN_GetReceivedId();               // Get 32 bit EXTENDED IDE

      CANMsgDLC = CAN_GetReceivedDLC();               // Get DLC

      for(i = 0; i <8; i++)

      {

         CANMsgData[i] = CAN_GetReceivedData(i);   // Get can msg data

      }

      CAN_RX();                                                   // Lastly call CAN_RX to process

   }

stm8s_it.h has the following two lines at the top:

@far @interrupt void CAN_RX_IRQHandler(void);

@far @interrupt void TIM2_UPD_OVF_IRQHandler(void);

Interrupt Vector table is as folows:

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, (interrupt_handler_t)CAN_RX_IRQHandler}, /* irq8 */

   {0x82, NonHandledInterrupt}, /* irq9 */

   {0x82, NonHandledInterrupt}, /* irq10 */

   {0x82, NonHandledInterrupt}, /* irq11 */

   {0x82, NonHandledInterrupt}, /* irq12 */

   {0x82, (interrupt_handler_t)TIM2_UPD_OVF_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 */

};

I am new to this processor/compiler so I reckon I must be doing something wrong. Can anybody point me in the right direction please?

Many thanks, Bruce

1 REPLY 1
ZDuka.1
Associate

Add the @svlreg keyword before your interrupt function name.

Like this:

 @svlreg INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8)

   {

      extern uint32_t CANMsgIde;

...