PIC12F1822 DAC

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
Sergejs
Posts: 143
http://meble-kuchenne.info.pl
Joined: Tue Oct 19, 2021 9:31 am
Has thanked: 73 times
Been thanked: 5 times

PIC12F1822 DAC

Post 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?

Sergejs
Posts: 143
Joined: Tue Oct 19, 2021 9:31 am
Has thanked: 73 times
Been thanked: 5 times

Re: PIC12F1822 DAC

Post by Sergejs »

There is with timings problem too.

Sergejs
Posts: 143
Joined: Tue Oct 19, 2021 9:31 am
Has thanked: 73 times
Been thanked: 5 times

Re: PIC12F1822 DAC

Post by Sergejs »

12f1822 DAC 5 bit.fcfx
(10.71 KiB) Downloaded 96 times

chipfryer27
Valued Contributor
Posts: 1110
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 278 times
Been thanked: 397 times

Re: PIC12F1822 DAC

Post 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

medelec35
Matrix Staff
Posts: 1432
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 506 times
Been thanked: 469 times

Re: PIC12F1822 DAC

Post 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.
Martin

Post Reply