// i8088W_PWMStart.cpp : Defines the entry point for the console application. // /* Using pac_i8088W.dll on XPAC-8000 series. */ // This demo shows how to send PWM output normally. // Using pac_i8088W_PWMStart to achieve this goal. #include "stdafx.h" #include #include "pac_i8088W.h" #pragma comment(lib,"pac_i8088W.lib") 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. start PWM output pac_i8088W_PWM_Start(slotIndex, channel); 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; }