I'm not new to programming or C, but I am very new to chip programming in particular and I'm having a lot of trouble finding and deciphering documentation.
To be specific, I am using MPLab X IDE in conjunction with the XC8 compiler. My chip is a PIC12F1501. My intent (for now) is to gently pulse an LED, but eventually it will be adapted to drive a speaker with a sine wave. Pretty sure my circuit is good as I can make an LED blink on and off with a digital output.
Now, I understand how to set the TRIS register so that the right legs are output or input as required. I know how to use ANSEL to set these pins into analog mode. What I cannot seem to fathom is what command or combination of commands I need to use to actually write an analog value to a pin. I've used the latch (LAT) to set a digital output, but I can't see how to do the same thing with an analog value.
From the data sheet for the chip I get the vague idea that I'm supposed to set the value of some other register representing the DAC to determine the level of voltage output, and then latch to 1 just as you would for digital output, but I'm not used to reading these things. I've tried a number of register names that are hinted in the documentation for the DAC but none of them compile.
I've tried snippets of code for other chips in the same approximate family and none of them compile either.
Can someone share a brief snippet demonstrating how analog output works in the PIC12F1501?