Page 1 of 1

PIC12F1822 DAC

Posted: Thu Feb 17, 2022 11:53 pm
by Sergejs
There is something wrong with digital to analog converter on port A0 in 12f1822.

Do not any works. Or have someone example how it works?

Re: PIC12F1822 DAC

Posted: Fri Feb 18, 2022 12:37 am
by Sergejs
There is with timings problem too.

Re: PIC12F1822 DAC

Posted: Fri Feb 18, 2022 12:41 am
by Sergejs
12f1822 DAC 5 bit.fcfx
(10.71 KiB) Downloaded 101 times

Re: PIC12F1822 DAC

Posted: Fri Feb 18, 2022 10:05 am
by chipfryer27
Hi

Sorry to be brief.

In Config you have selected HS-Osc as your clock source, and have PLL enabled. What crystal are you using? From memory (as I don't have the datasheet to hand) the PLL will only multiply either the 8MHz internal Osc or the External Osc (which you have selected) up to a maximum speed most likely to be 32MHz (sorry don't have datasheet).

Again in Config, you have 20MHz selected as Clock Speed. This doesn't actually set the speed it just lets Flowcode know what speed you are running at so it can calculate delays etc. There is plenty of info in the forums if you do a search regarding this.

I'd first try disabling the PLL and setting clock speed to whatever your crystal is. This should at least get your timings right.

Hope this helps

Regards

Re: PIC12F1822 DAC

Posted: Fri Feb 18, 2022 11:06 am
by medelec35
Hi
I have just checked the DAC component and it's working as expected.
Having looked at the DAC within your flowchart you have got the variable used for DAC going above the maximum value of 31.
You will need to take into account that the DAC will treat 32 as 0, 33 as 1 as the DACCON1 register used to set DAC can only accept values from 0 to 31, hence the 5 bit DAC.
Chipfryer is correct. that your configuration settings are wrong.
Before you start to create a project, I would always recommend setting up a 1-second flasher.
It will save you headaches later.