/************ Author: Martin Hsu Email: service@icpdas.com Date 2007/11/6 i8088 is a PWM module with 8 DI Pins can be defined as hardware trigger pin it also can set PWM as synchrous mode [Normal PWM pulse define as duty] 1. i8088W_InitLib(slot) 2. i8088W_SetPWMCountMode(slot,ch,countMode); //0 burst; 1 continous if burst mode i8088W_SetBurstCount(slot,ch,burstCount); 3. i8088W_SetPWMDuty(slot,ch,hz,duty); 4. i8088W_PWM_Start(slot,ch); [Normal PWM pulse define pulse width] 1. i8088W_InitLib(slot) 2. i8088W_SetPWMCountMode(slot,ch,countMode); //0 burst; 1 continous if burst mode i8088W_SetBurstCount(slot,ch,burstCount); 3. i8088W_SetPWMDutyCount(slot,ch,hz,highDutyCount,lowDutyCount); 4. i8088W_PWM_Start(slot,ch); [Synchrous PWM pulse define as duty] 1. i8088W_InitLib(slot) 2. i8088W_SetPWMCountMode(slot,ch,countMode); //0 burst; 1 continous if burst mode i8088W_SetBurstCount(slot,ch,burstCount); 3. i8088W_SetPWMDuty(slot,ch,hz,duty); 4. i8088W_SetSyncChannel(slot,ch,enBit);//enBit=1 to set as synchrous channel 5. i8088W_SetSyncStart(slot); [Hardware trigger PWM pulse define as duty] 1. i8088W_InitLib(slot) 2. i8088W_SetPWMCountMode(slot,ch,countMode); //0 burst; 1 continous if burst mode i8088W_SetBurstCount(slot,ch,burstCount); 3. i8088W_SetPWMDuty(slot,ch,hz,duty); 4. i8088W_SetHardwareTrigChannel(slot,ch,enBit);//enBit=1 to set as start flag; enBit=0 to set as stop flag. 5. The wait the hardware DI pin trigger signal to start or to stop the PWM pulse; #define OK 0 #define ID_ERROR -1 #define SLOT_OUT_RANGE -2 #define CHANNEL_OUT_RANGE -3 #define SELECT_CHANNEL_ERROR -4 #define HI_DUTY_OUT_RANGE -5 #define LO_DUTY_OUT_RANGE -6 *******************************/ /******************************** i8088 Error Code definition *******************************/ #include "..\..\Lib\8000E.h" #include "..\..\Lib\8088W.h" int slotIndex=-1; int runFlag=1; int startMode=0; char title[]="Demo for i-8088 PWM"; void showMenu(int step) { Print("\n\n****************************************************\n\r"); switch(step) { case 1: Print("Enter '1' Step 1 to set PWM mode.\n\r"); break; case 2: Print("Enter '2' Step 2 to set PWM duty.\n\r"); break; case 3: Print("Enter '3' Step 3 to start PWM.\n\r"); break; case 4: Print("Enter '4' Step 4 to stop PWM.\n\r"); break; } Print("Enter 'Q' or 'q' to Exit the program.\n\r"); } void Find_i8088W(void) { int i,id,Base; for (i=0; i