Generally speaking, mcus have alternate uses for any pin. Sometimes, the power-on state / mode is not (digital) GPIO - PICs as you have found out power up in the analog mode. Other PICs may also default some of their pins for comparators.
Many PICs provide a gpio initialization sequence in the GPIO section of the datasheet, or to identify all relevant registers / bits, etc.
I always execute a routine, called mcu_init(), as the first user-space routine to reset the pins to digital IO. On some mcus, that routine could be an empty routines - AVRs for example. But it is a good idea to always have that.
Generally speaking, mcus have alternate uses for any pin. Sometimes, the power-on state / mode is not (digital) GPIO - PICs as you have found out power up in the analog mode. Other PICs may also default some of their pins for comparators.
Many PICs provide a gpio initialization sequence in the GPIO section of the datasheet, or to identify all relevant registers / bits, etc.
I always execute a routine, called mcu_init(), as the first user-space routine to reset the pins to digital IO. On some mcus, that routine could be an empty routines - AVRs for example. But it is a good idea to always have that.
一周热门 更多>