Skip to content

CH32X035 compilation broken in HardwareTimer.cpp #77

@maxgerhardt

Description

@maxgerhardt

The lines

#ifdef TIM2_BASE
NVIC_EnableIRQ(TIM2_IRQn);
#endif

fail to compile when selecting a CH32X035 board.

/home/runner/.platformio/packages/framework-arduino-openwch-ch32/cores/arduino/HardwareTimer.cpp:73:18: error: 'TIM2_IRQn' was not declared in this scope
   NVIC_EnableIRQ(TIM2_IRQn);
                  ^~~~~~~~~
/home/runner/.platformio/packages/framework-arduino-openwch-ch32/cores/arduino/HardwareTimer.cpp:73:18: note: suggested alternative: 'TIM3_IRQn'
   NVIC_EnableIRQ(TIM2_IRQn);
                  ^~~~~~~~~
                  TIM3_IRQn

This is because the CH32X035 does define TIM2_BASE macro but doesn't have a TIM2_IRQn interrupt.

#define TIM2_BASE (APB1PERIPH_BASE + 0x0000)
#define TIM3_BASE (APB1PERIPH_BASE + 0x0400)

It has these though

TIM2_UP_IRQn = 38, /* TIM2 Update Interrupt */
USART2_IRQn = 39, /* USART2 global Interrupt */
EXTI15_8_IRQn = 40, /* External Line[15:8] Interrupts */
EXTI25_16_IRQn = 41, /* External Line[25:16] Interrupts */
USART3_IRQn = 42, /* USART3 global Interrupt */
USART4_IRQn = 43, /* USART4 global Interrupt */
DMA1_Channel8_IRQn = 44, /* DMA1 Channel 8 global Interrupt */
USBFS_IRQn = 45, /* USBFS Host/Device global Interrupt */
USBFSWakeUp_IRQn = 46, /* USBFS Host/Device WakeUp Interrupt */
PIOC_IRQn = 47, /* PIOC global Interrupt */
OPA_IRQn = 48, /* OPA global Interrupt */
USBPD_IRQn = 49, /* USBPD global Interrupt */
USBPDWakeUp_IRQn = 50, /* USBPD WakeUp Interrupt */
TIM2_CC_IRQn = 51, /* TIM2 Capture Compare Interrupt */
TIM2_TRG_COM_IRQn = 52, /* TIM2 Trigger and Commutation Interrupt */
TIM2_BRK_IRQn = 53, /* TIM2 Break Interrupt */
TIM3_IRQn = 54, /* TIM3 global Interrupt */

So maybe TIM2_CC_IRQn and TIM2_UP_IRQn should be used for the CH32X035?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions