User Guide

Code
2021
Microchip Technology Inc. and its subsidiaries
DS50003218A-page 29
for(temp=0;temp<360;temp++)
{
StartADCoversion();
for(del=0;del<(ADRES>>2);del++); // delay based from ADC pot reading
I2C1Write(CNTRLBYTE,DAC0,*(SinePtr+temp));
SW1();
SW2();
}
LED2^=1;
LED3=0;
LED4=0;
LED5=0;
}
I2C1_Initialize();
while(Status==I2C_SAWTOOTH)
{
for(temp=0;temp<0xFFF;(temp=temp+20))
{
StartADCoversion();
for(del=0;del<(ADRES>>2);del++); // delay based from ADC pot reading
I2C1Write(CNTRLBYTE,DAC0,temp);
SW1();
SW2();
}
LED2=0;
LED3^=1;
LED4=0;
LED5=0;
}
}
while(1);
/*******Example for read routines************/
I2CReadData=I2C1ReadLastAddr(CNTRLBYTE); // Read the last address accessed
I2CReadData=I2C1Read(CNTRLBYTE,DAC0); // Read DAC0
SPIReadData=SPI1_ReadWord(DAC0);
while(1);
/*******Example for read routines************/
}
/****************************************************************
* Function to Write to SPI1 Module
****************************************************************/