Sei sulla pagina 1di 2

To turn on pin P2[1] use

PRT2DR |= 0x02;

To turn off, use

PRT2DR &= (~0x02);

By using OR and AND boolean you will not affect the other pins on the port.

If you are not sure of what mask to use and are unfamiliar with hexadecimal then the following
table might be of some use:
Pin 0 = 0x01
Pin 1 = 0x02
Pin 2 = 0x04
Pin 3 = 0x08
Pin 4 = 0x10
Pin 5 = 0x20
Pin 6 = 0x40
Pin 7 = 0x80
AMX_ IN Analog Input Select Register
Permite controlar en tiempo de ejecucin el mux AnalogColumn_InputMux_1.
7:6 ACI3[1:0] Selects the Analog Column Mux 3.
00b ACM3 P0[0]
01b ACM3 P0[2]
10b ACM3 P0[4]
11b ACM3 P0[6]
5:4 ACI2[1:0] Selects the Analog Column Mux 2.
00b ACM2 P0[1]
01b ACM2 P0[3]
10b ACM2 P0[5]
11b ACM2 P0[7]
Note ACol2Mux (ABF_CR0, Address 1,62h)
0 AC2 = ACM2
1 AC2 = ACM3
3:2 ACI1[1:0] Selects the Analog Column Mux 1. For 1 column, these are even inputs.
00b ACM1 P0[0]
01b ACM1 P0[2]
10b ACM1 P0[4]
11b ACM1 P0[6]
Note ACol1Mux (ABF_CR0, Address 1,62h)
0 AC1 = ACM1
1 AC1 = ACM0
1:0 ACI0[1:0] Selects the Analog Column Mux 0. For 1 column, these are odd inputs.
00b ACM0 P0[1]
01b ACM0 P0[3]
10b ACM0 P0[5]
11b ACM0 P0[7]

ABF_CR

Empezar y detener un contador.

void estado(void)
{
if (PRT0DR & 0x40)
{
// Pin is set. Add code to process
//LCD_Position(0,0);
//LCD_PrCString("Conectado");
//LCD_Delay50uTimes(10);
Counter16_1_Start();
}

if (!(PRT0DR & 0x40))
{
// Pin is set. Add code to process
//LCD_Position(0,0);
//LCD_PrCString("Desconectado");
//LCD_Delay50uTimes(10);
Counter16_1_Stop();
}
}

Sobre el Pin0[6], interrupcin por GPIO, y puesto en
changefromread.[La interrupcin se desencadena, en flanco de subida
y en flanco de bajada].

Potrebbero piacerti anche