[En-Nut-Discussion] Pin I/O

Sigurd Kleppan 021243 at student.hit.no
Fri Feb 6 14:12:42 CET 2004


I know how to set output pins.
outp(0xff,PORTA);
In this commando you have to set all 8 pins in one operation.

I only want to set one pin without setting the other 7 pins. Can i do this with following commandos?
If this is possible, how to i find the unique adress of each pin?

By the way, do NUT/OS have some commando to send serial word through the I/O ports?


This is a code i have found used by a another microcontroller.
The code is used to get a temperature from DS1620.

//Setting adress of the pins
sbit    RST     = 0xA2;                 /* DS1620 reset line            */
sbit    CLK     = 0xA3;                 /* DS1620 clock line            */
sbit    DQ      = 0xA4;                 /* DS1620 data  line    

void  Put1620byte(unsigned char m)

{
unsigned char k,b=1;
    RST=1;
    for (k=0; k<8; k++)
       {
        CLK=0;
        DQ = (m & b);                                /* Send bit to 1620     */
        CLK=1;
        b=(b<<1);                            /* Setup to send next bit  */
       }
return;
}


unsigned char  Get1620byte( void )
{
unsigned char j,k=0,b=1;
k=0;
b=1;
    for (j=0; j<8; j++)
       {
        CLK=0;
        if (DQ) k|=b;                                /* Read bit and or if = 1  */
        CLK=1;
        b=(b<<1);                            /* Setup for next read and or */
       }
return k;
}

void main(){
 RST=1;
 Put1620byte(0xAA);                              /* read temp command    */
 temp_and_half_bit = Get1620byte();           /* read 1st byte of temp   */
 sign_bit = Get1620byte();                    /* read 2nd byte of temp   */
 RST=0;
}




More information about the En-Nut-Discussion mailing list