void InitRegisters()
{
PORTA = 0;
ANSELA = 0;
TRISA = 0;
OSCCON = 0b1000; // run internal oscillator at 31kHz LF
FVRCON = 0b10001000; // enable fixed voltage reference for DAC, set gain = 2 to give a ref volt of 2.048V
}
void main()
{
InitRegisters();
DACCON0 = 0b10101000; // DAC enabled, DAC output available on DACOUT pin, FVR as positive voltage source
DACCON1 = 0x1F;
while(1)
{
while (DACCON1-- >1); // go from DACCON1 = 31 to DACCON1 = 0
while (DACCON1++ < 30); // go from DACCON1 = 1 to DACCON1 = 31
}
}
And here are the oscilloscope readings:


No comments:
Post a Comment