![Melec C-875 Скачать руководство пользователя страница 94](http://html1.mh-extra.com/html/melec/c-875/c-875_instruction-manual_1767048094.webp)
- 94 -
16-7.PULSE COUNTER Read Program Example
The following offers an example of the function that utilizes the PULSE COUNTER counting as the return
value.
/*-----------------------------------*/
/*
COUNTER READ
*/
/*-----------------------------------*/
long
xcntred( void )
{
long
a;
outp(XMCCCOM ,0xfc);
/* PULSE COUNTER PORT SELECT COMMAND OUT */
*( (UC *)&a + 2 ) = inp(XMCCDT1);
/* COUNTER MSB IN */
*( (UC *)&a + 1 ) = inp(XMCCDT2);
*( (UC *)&a ) = inp(XMCCDT3);
/* COUNTER LSB IN */
if( (*( (UC *)&a + 2 ) & 0x80 ) != 0 )
/* SIGN BIT ON ? */
{
*( (UC *)&a + 3) = 0xff;
} else {
*( (UC *)&a + 3) = 0x00;
}
return( a );
}
Note: The PULSE COUNTER PORT SELECT is valid only when other counter ports or the speed port is selected.
It is not needed when the PULSE COUNTER PORT is already selected.
Содержание C-875
Страница 98: ... 98 2 M TYPE 3 H TYPE ...