Port C as an output

Icône de l'outil pédagogique Utilization of the pins C1 and C2 as digital outputs

Pins C1 and C2 are used for the PWM outputs of the micro-controller, which we will study further. They can already be used as digital outputs, since it is possible to display their status on the simulator. In order to do this, we need to activate the view « oscilloscope » :

In order to configure the two pins as outputs, we need only to force to 0 the bits 1 and 2 of the TRISC register : TRISC &= 0xF9;

To force pin C1 to 0 :

PORTC &= 0xFD;

To force pin C1 to 1 :

PORTC |= 0x02;

To force pin C12to 0 :

PORTC &= 0xFB;

To force pin C2 to 1 :

PORTC |= 0x04;