//----------------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------------
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include "PSoCDynamic.h"
#pragma interrupt_handler PSoC_GPIO_ISR
void swichset (void) ;
WORD PWMADCData (void) ;
BYTE SET1,s1,WD;
int i,time1,t1;
long WD1,WD2,WD3,WD4,ADdata;
WORD PWMData;
void main(void)
{
time1=0;
PRT0IC0 |= 0x10;
PRT0IC1 |= 0x10;
PRT0IE |= 0x10;
s1=0;
M8C_EnableGInt; // Enable Global Interrupt
M8C_EnableIntMask(INT_MSK0, INT_MSK0_GPIO);
PWM8_1_WritePeriod(255);
PWM8_2_WritePeriod(255);
while(1)
{time1++;
swichset();
if(time1>=5000)
{
PWMData=(BYTE)PWMADCData ();
time1=0;
}
WORD PWMADCData (void)
{ int PWMData1,data1;
BYTE data;
LoadConfig_DAC();
// perform sample only if the conguration is loaded properly
if (IsDACLoaded() )
{
PGA_1_Start(PGA_1_MEDPOWER);
ADCINC_1_Start(ADCINC_1_HIGHPOWER); // Apply power to the SC Block
ADCINC_1_GetSamples(0); // Have ADC run continuously
while(ADCINC_1_fIsDataAvailable() == 0); // Loop until value ready
ADCINC_1_iClearFlagGetData(); // Clear ADC flag and get data
PWMData1=ADCINC_1_iGetData()+2048;
if(PWMData1>=16)
{
data1=PWMData1/16;
}