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

issue with GD32F303C DAC1 #90

Closed
flute2k3 opened this issue Jun 4, 2023 · 6 comments
Closed

issue with GD32F303C DAC1 #90

flute2k3 opened this issue Jun 4, 2023 · 6 comments
Assignees
Labels
bug Something isn't working Component: DAC Regarding the DAC component

Comments

@flute2k3
Copy link

flute2k3 commented Jun 4, 2023

I test below codes in setup with int V_set = 2048

void setup(){
pinMode(PA4, OUTPUT);
pinMode(PA5, OUTPUT);
analogWriteResolution(12);
analogWrite(PA4, V_set);
analogWrite(PA5, V_set);
}

it works good with PA4 (DAC0), measured voltage is 1.67V, however the voltage measured at in PA5 (DAC1) is not expected, it stays at 13mV constantly regardless of the V_set value.

I tested two boards with CC and CG chips, same issue, I assume it much be the software issue.

Thanks

@maxgerhardt maxgerhardt self-assigned this Jun 4, 2023
@maxgerhardt
Copy link
Member

PA5 was not correctly mapped to DAC1 indeed in the GD32F303CC_GENERIC variant.

Fixed per a1b0f8b

Can you update and retest? Just CLI -> pio pkg update -g -p gd32.

@maxgerhardt maxgerhardt added bug Something isn't working Component: DAC Regarding the DAC component labels Jun 4, 2023
@flute2k3
Copy link
Author

flute2k3 commented Jun 4, 2023

Thank you for quick action, now DAC1 is good with 1.67V output, however I get 0,63V at PA4 (DAC0). it looks to me the DAC0 and 1 can not work at the same time?

@maxgerhardt
Copy link
Member

maxgerhardt commented Jun 4, 2023

No I think we have another bug. The analog.cpp function does a dac_deinit(); when it sets up a new DAC perihperal. So when you use PA4 then PA5, the setup of PA5 causes an unconditional reset of the DAC clock domain and kills the previous config for PA4. I'll fix it.

@maxgerhardt
Copy link
Member

I pushed

edc5d2b

could you update & retest?

@flute2k3
Copy link
Author

flute2k3 commented Jun 4, 2023

TERRIFIC!!! now I get the same value at PA4 and PA5, amazing work maxgerhardt !

@maxgerhardt
Copy link
Member

Great! Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Component: DAC Regarding the DAC component
Projects
None yet
Development

No branches or pull requests

2 participants