// i8088W_HardwareTrigger.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 trigger PWM output by corresponding DI pin (hardware). // Using pac_i8088W_SetHardwareTrigChannel to achieve this goal. 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 hardware trigger channel and wait for DI signal to start PWM outputs. //triggerState =0(trigger disabled); 1(start trigger); 2(stop trigger) pac_i8088W_SetHardwareTrigChannel(slotIndex, channel, 1); printf("\n\n"); printf("In the slot: %d, and in the channel: %d\n", slotIndex, channel); printf("frequency= %u, duty cycle= %u, burst count=%d\n", freq, dutyCycle, burstCount); printf("PWM start!\n"); } getchar(); return 0; }