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

Compile failure for CH32V303CBT6 #348

Open
maxgerhardt opened this issue Jul 13, 2024 · 3 comments
Open

Compile failure for CH32V303CBT6 #348

maxgerhardt opened this issue Jul 13, 2024 · 3 comments

Comments

@maxgerhardt
Copy link
Contributor

Not sure exactly how this should work, but I'm getting

In file included from src\blink.c:1:
C:\Users\Max\.platformio\packages\framework-ch32v003fun\ch32v003fun/ch32v003fun.h:12942:6: error: #error "Invalid PLL multiplier"
     #error "Invalid PLL multiplier"
      ^~~~~

My CH32V303CBT6 board definition has -DCH32V30x -DCH32V303 -DCH32V30x_D8 defined (globally). My source for that is the datasheet.

Then

#if !defined( FUNCONF_PLL_MULTIPLIER )
#if defined(FUNCONF_USE_PLL) && FUNCONF_USE_PLL
#if defined(CH32V10x)
#define FUNCONF_PLL_MULTIPLIER 10 // Default: 8 * 10 = 80 MHz
#elif defined(CH32V20x)
#define FUNCONF_PLL_MULTIPLIER 18 // Default: 8 * 18 = 144 MHz
#elif defined(CH32V30x)
#define FUNCONF_PLL_MULTIPLIER 18 // Default: 8 * 18 = 144 MHz
#else // CH32V003
#define FUNCONF_PLL_MULTIPLIER 2 // Default: 24 * 2 = 48 MHz
#endif
#else
#define FUNCONF_PLL_MULTIPLIER 1
#endif
#endif

is going to activate

#define FUNCONF_PLL_MULTIPLIER 18	// Default: 8 * 18 = 144 MHz

but

#if defined(CH32V10x) || defined(CH32V20x) || defined(CH32V30x_D8)
#if FUNCONF_PLL_MULTIPLIER == 2
#define PLL_MULTIPLICATION RCC_PLLMULL2
#elif FUNCONF_PLL_MULTIPLIER == 3
#define PLL_MULTIPLICATION RCC_PLLMULL3
#elif FUNCONF_PLL_MULTIPLIER == 4
#define PLL_MULTIPLICATION RCC_PLLMULL4
#elif FUNCONF_PLL_MULTIPLIER == 5
#define PLL_MULTIPLICATION RCC_PLLMULL5
#elif FUNCONF_PLL_MULTIPLIER == 6
#define PLL_MULTIPLICATION RCC_PLLMULL6
#elif FUNCONF_PLL_MULTIPLIER == 7
#define PLL_MULTIPLICATION RCC_PLLMULL7
#elif FUNCONF_PLL_MULTIPLIER == 8
#define PLL_MULTIPLICATION RCC_PLLMULL8
#elif FUNCONF_PLL_MULTIPLIER == 9
#define PLL_MULTIPLICATION RCC_PLLMULL9
#elif FUNCONF_PLL_MULTIPLIER == 10
#define PLL_MULTIPLICATION RCC_PLLMULL10
#elif FUNCONF_PLL_MULTIPLIER == 11
#define PLL_MULTIPLICATION RCC_PLLMULL11
#elif FUNCONF_PLL_MULTIPLIER == 12
#define PLL_MULTIPLICATION RCC_PLLMULL12
#elif FUNCONF_PLL_MULTIPLIER == 13
#define PLL_MULTIPLICATION RCC_PLLMULL13
#elif FUNCONF_PLL_MULTIPLIER == 14
#define PLL_MULTIPLICATION RCC_PLLMULL14
#elif FUNCONF_PLL_MULTIPLIER == 15
#define PLL_MULTIPLICATION RCC_PLLMULL15
#elif FUNCONF_PLL_MULTIPLIER == 16
#define PLL_MULTIPLICATION RCC_PLLMULL16
#elif defined(CH32V20x) && FUNCONF_PLL_MULTIPLIER == 18
#define PLL_MULTIPLICATION RCC_PLLMULL18
#else
#error "Invalid PLL multiplier"
#endif

will run into the #error because the #elif defined(CH32V20x) && FUNCONF_PLL_MULTIPLIER == 18 does not hold for it.

Is that a bug in my activated macros for the CH32V303CBT6 or does ch32v003fun incorrectly account for it?

@cnlohr
Copy link
Owner

cnlohr commented Jul 14, 2024

I regret I don't have a CH32V303 here of any kind - I would expect it should use FUNCONF_PLL_MULTIPLIER 18

I am 99% sure we should just remove the CH32V20x precondition from line 12949.

@cnlohr
Copy link
Owner

cnlohr commented Jul 14, 2024

Can you remove and test? If so, can you make a PR?

@cnlohr
Copy link
Owner

cnlohr commented Jul 14, 2024

Blame falls on @AlexanderMandera -- this line looks like an actual error. But the plot is so messy...
image
Just the way to get there is quite messier than most.

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

2 participants