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

Does the GD32F303CCT6 have a FPU? #4

Open
djix123 opened this issue Mar 15, 2021 · 7 comments
Open

Does the GD32F303CCT6 have a FPU? #4

djix123 opened this issue Mar 15, 2021 · 7 comments

Comments

@djix123
Copy link

djix123 commented Mar 15, 2021

When I try and compile code using hardware floating point I get a HardFault exception on the first instruction that tries it execute a floating point instruction. The fault indicated is NOCP despite have written to 0b11 to CP_10 and CP_11 of the CPACR.

I've tried with IAR, Keil and GCC each with the same results. Indeed, if I take the example 04-MSC_internal_flash and then adding some floating point arithmetic to main() results in the HardFault. This can be cured by changing the 'Floating Point Hardware' from 'Use Single Precision' to 'Not Used'. The compiler no longer generates FPU instructions and the code works.

@WeActStudio
Copy link
Owner

Yes, We tested that its FPU was OK,
Keil 'Floating Point Hardware' set 'Use Single Precision'

float a=0;
a=1.f/3.f;

Result is a=0.333333343

@djix123
Copy link
Author

djix123 commented Mar 16, 2021

That's interesting it doesn't work for me at all unfortunately - when I read back the CPACR register after writing 0b11 to CP_10 and CP_11 they are still 0.
(I have no problems with an STM32F303K8 part or an STM32F411CE part - everything works as expected).

Would it be possible to add another (minimal) example project in the examples directory with this working?

@djix123
Copy link
Author

djix123 commented May 28, 2021

As a further update I received a few more BluePill-Plus / GD32F303 boards recently.

I built the GNU-template project that has been added to repository (thanks!) and enabled the FPU compiler settings. The new boards work perfectly fine - and the temperate and Vref is calculated using the FPU.
But, when I use my original boards the code hard faults with a NOCP fault per previous comments.
(same binary uploaded to the boards)

Looking at the processor markings the two sets of boards clearly have processors from different batches as the markings are different.

@Liuyufanlyf
Copy link
Contributor

Liuyufanlyf commented May 29, 2021

I'm glad to hear that my contribution is helpful, keil is a powerful ide, but I believe open source toolchain is better.

Considering your situation, it's possible that some batches have bugs in fpu.

Have a nice day!

@djix123
Copy link
Author

djix123 commented May 29, 2021

Yes, thanks! Very helpful indeed! I've also attached some photos (not the best quality) of the MCU with working FPU and the MCU with a non-working FPU. Hope that's helpful.
GD32F303_workingFPU
GD32F303_notWorkingFPU

@djix123
Copy link
Author

djix123 commented May 22, 2022

Eventually got around to replacing an MCU with a non-working FPU with a replacement part (GD32F303CG).
Example project using the GigaDevice SPL

@hgl10
Copy link

hgl10 commented May 30, 2022

我也遇到了类似的问题。我手里有两个BluePill Plus(GD32F303),一个编号是JJ2042,一个是AC2137。编号是JJ2042的芯片,不能启用Single Precision,如果启用芯片会直接不工作,连闪烁LED灯都做不到。如果不启用就一切正常。但编号AC2137的板子都正常。
image

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

4 participants