1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| //#include "adioctl.h"
#include "dio_tc.h"
void CALLBACK TxProcessEvent(const short h, const WPARAM wParam, const ULONG PortC)
{
printf(" The periodic task !");
}
//
int main()
{
short hBoard;
short hTCINTPortA;
// register a suitable card
hBoard = registerBoardEx(0);
if (hBoard < 0)
{
printf("\n\rUnable to find Amplicon PCE DIO CT card");
return -1;
}
// Je mets le compteur en mode 2 : Rate Generator. C'est un mode périodqiue //qui divise par N ou N est l'initial count (si j'ai bien compris)
if (TCsetMode(hBoard,Z1,0,MODE2) < 0){
printf("TCsetMode failed \n");
return -1;
}
if (TCsetGate(hBoard,Z1,0,GAT_VCC) < 0){
printf("TCsetGate failed \n");
return -1;
}
if ( TCsetClock(hBoard,Z1,0,CLK_EXT)){
printf("TCsetClock failed \n");
return -1;
}
if (TCsetCount(hBoard,Z1,0,1023) < 0){
printf("TCsetCount failed\n");
return -1;
}
hTCINTPortA = TCsetUserInterrupt( hBoard
, &TxProcessEvent
, 0
, Z1
, 0 //
, Z1
, 0
, 0
, 0
);
if (hTCINTPortA < 0)
{
printf("\n\r Error interrupt");
FreeBoard(hBoard);
return -1;
}
enableInterrupts( hBoard );
Sleep(0);
while(1){
TxProcessEvent(hBoard, 0, 0);
}
disableInterrupts( hBoard );
TCfreeUserInterrupt(hBoard, hTCINTPortA);
FreeBoard(hBoard);
return 0;
} |
Partager