Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CH32X035 compilation broken in HardwareTimer.cpp #77

Open
maxgerhardt opened this issue Mar 27, 2024 · 1 comment
Open

CH32X035 compilation broken in HardwareTimer.cpp #77

maxgerhardt opened this issue Mar 27, 2024 · 1 comment

Comments

@maxgerhardt
Copy link
Contributor

maxgerhardt commented Mar 27, 2024

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?

@maxgerhardt maxgerhardt changed the title CH32X035 compilation broken in HardwareTimers.cpp CH32X035 compilation broken in HardwareTimer.cpp Mar 27, 2024
@maxgerhardt
Copy link
Contributor Author

I have attempted a fix for that in Community-PIO-CH32V@bbf32d3, for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant