This is done by setting bits in DDRx to zero. In order to read the data from port pin, first you have to change port’s data direction to input. PINx (Port IN) used to read data from port pins. to make lower nibble of port B as output and higher nibble as input :. to make all pins of port A as output pins :.to make all pins of port A as input pins :.Writing 0 to a bit in DDRx makes corresponding port pin as input, while writing 1 to a bit in DDRx makes corresponding port pin as output. Means its setting determines whether port pins will be used for input or output. (x can be replaced by A,B,C,D as per the AVR you are using)ĭDRx (Data Direction Register) configures data direction of port pins. Bit0 of these registers is associated with Pin0 of the port, Bit1 of these registers is associated with Pin1 of the port, …. Every bit in those registers configure pins of particular port. Every port has 3 registers associated with it each one with 8 bits. Got that ? If not read this para again.Ītmel AVR is 8 bit microcontroller. To change setting for one single pin of the port, you have to change a particular bit in associated register. Thus in order to change setting for one port, you have to change setting for all port pins of that port. NOTE : I will frequently refer to ‘configuring pin’ or simply ‘pin’.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |