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.
QQ图片20130621144321.jpg (269.91 KB, 下载次数: 1)
下载附件
2013-6-21 14:44 上传
总算把LCD点亮了!
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.
原来,手册上的引脚功能说明中,有标ANx的IO都是带有模拟输入功能的,必须将其设置为数字输出。
在学习中断,发现无论是定时器0还是定时器1还是其它,
中断程序都是这个:
void interrupt isr(void)
{
}
不像51单片机那样带有中断号来对应中断源。
难道PIC的所有中断程序都写在void interrupt isr(void)里,然后用判断语句来识别中断源吗?
一周热门 更多>