NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Setting Pin Low

March 09, 2011
by dgikuljot
dgikuljot's Avatar

According to the nerdkits guide this is how you set a pin to output ground or low:

 PORTC &= ~(1<<PC3);// set PC3 low

 the way i do it is : PORTC |= (0<<2).

Is my method good also, or is it bad for mcu in any way. Thanks, Kuljot Dhami

March 09, 2011
by esoderberg
esoderberg's Avatar

dgikuljot,

See page 58 of NK guide. Say for example PC3 is high and all else on PORTC off, then PORTC = 00000100 and what your code does is: PORTC = 00000100 | 00000000 = 00000100. IE PC3 still high, so I don't think your method will work as you intend.

Eric

Post a Reply

Please log in to post a reply.

Did you know that LEDs (light emitting diodes) only conduct current in one direction, like normal diodes? Learn more...