// i8088W_SyncStart.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "pac_i8088W.h" #include #pragma comment(lib,"pac_i8088W.lib") /* Using pac_i8088W.dll on XPAC-8000 series. */ // This demo shows how to Synchronized PWM output through many channels. // Using pac_i8088W_SetSyncChannel and pac_i8088W_SyncStart to achieve this goal. // In this demo we show you how to synchronize two channels, channel 0 and channel 7. // // Note: pac_i8088W_SyncStart just starts PWM outputs at the same time in the synchronized channels. // Each channel can have its own frequency, duty cycle, count mode, burst count. #define ENABLED 1 static int slotIndex=-1; int main(int argc, char* argv[]) { //Declaration and default value assignment int slot = -1; int channel = 0; const unsigned long freq = 1000; const unsigned int dutyCycle = 50; int countMode = 0; //1: Continuos ;0: Burst count unsigned int burstCount = 1000; for(slot=0;slot<8;slot++) { //1. init the I-8088W module if(pac_i8088W_Init(slot)==0) { slotIndex=slot; break; } } if(slotIndex==-1) { printf("There is no i8088W at Backplane\n"); getchar(); return -1; } else { printf("There is an i8088W at slot %d\n",slotIndex); } for(channel=0;channel<8;channel++) { //2. set the frequency and duty cycle. //(note: the possible value of duty cycle is decided by frequency. // this is because PWM output is synthesized by 1 us pulse. pac_i8088W_SetPWMDuty(slotIndex, channel, freq, dutyCycle); //3. set count mode. //(continuous mode outputs forever; burst count mode outputs only specified number of counts.) pac_i8088W_SetPWMCountMode(slotIndex, channel, countMode); //1: Continuos ;0: Burst count //4. set the number of count for burst count mode pac_i8088W_SetBurstCount(slotIndex, channel, burstCount); //5. set the synchronized channels. (Here we set channel 0 and channel 7 synchronized.) pac_i8088W_SetSyncChannel(slotIndex, channel, ENABLED); } //6. start Synchronized PWM output pac_i8088W_Sync_Start(slot); printf("\n\n"); printf("In the slot: %d, and in the channel 0 and 7\n", slotIndex); printf("Synchronized PWM start!\n"); getchar(); return 0; }