在线时间9 小时
UID326209
注册时间2011-11-3
NXP金币0
该用户从未签到
注册会员

- 积分
- 65
- 最后登录
- 1970-1-1
|
我在一个最小系统(只有单片机)的板子上,将所有的引脚全部设置为IO口(除了SWD_CLK,SWD_DIO,nReset三个脚外),并且全部输出为高,
void PORT_Init(void)
{
SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK);//允许PORTA和PORTB的时钟
PORTA_PCR3 = PORT_PCR_MUX(0x01); // PTA3为IO口
PORTA_PCR4 = PORT_PCR_MUX(0x01); // PTA4为IO口
PORTA_PCR5 = PORT_PCR_MUX(0x01); // PTA5为IO口
PORTA_PCR6 = PORT_PCR_MUX(0x01); // PTA6为IO口
PORTA_PCR7 = PORT_PCR_MUX(0x01); // PTA7为IO口
PORTA_PCR8 = PORT_PCR_MUX(0x01); // PTA8为IO口
PORTA_PCR9 = PORT_PCR_MUX(0x01); // PTA9为IO口
PORTA_PCR12 = PORT_PCR_MUX(0x01); // PTA12为IO口
PORTB_PCR0 = PORT_PCR_MUX(0x01); // PTB0为IO口
PORTB_PCR1 = PORT_PCR_MUX(0x03); // PTB1为RXD
PORTB_PCR2 = PORT_PCR_MUX(0x03); // PTB2为TXD
PORTB_PCR3 = PORT_PCR_MUX(0x01); // PTB3为IO口
PORTB_PCR4 = PORT_PCR_MUX(0x01); // PTB4为IO口
PORTB_PCR5 = PORT_PCR_MUX(0x01); // PTB5为IO口
PORTB_PCR6 = PORT_PCR_MUX(0x01); // PTB6为IO口
PORTB_PCR7 = PORT_PCR_MUX(0x01); // PTB7为IO口
PORTB_PCR10 = PORT_PCR_MUX(0x01); // PTB10为IO口
PORTB_PCR11 = PORT_PCR_MUX(0x01); // PTB11为IO口
PORTB_PCR13 = PORT_PCR_MUX(0x01); // PTB13为IO口
GPIOA_PDDR |= (BIT(3)+BIT(4)+BIT(5)+BIT(6)+BIT(7)+BIT(8)+BIT(9)+BIT(12));
GPIOB_PDDR |= (BIT(0)+BIT(3)+BIT(4)+BIT(5)+BIT(6)+BIT(7)+BIT(10)+BIT(11)+BIT(13));
GPIOA_PSOR |= BIT(3)+BIT(4)+BIT(5)+BIT(6)+BIT(7);
GPIOA_PCOR |= BIT(8)+BIT(9)+BIT(12);
GPIOB_PSOR |= (BIT(3)+BIT(4)+BIT(6)+BIT(7)+BIT(10)+BIT(11)+BIT(13));
GPIOB_PCOR |= BIT(0)+BIT(5);
}
主程序里直接
int main (void)
{
PORT_Init();
while(1)
{
enter_vlps();
}
}
在该状态下测试,板子上的电流为何不是很稳定,有时为2uA左右,但是多复位几次后,有时又会到16uA左右,有没有人遇到这个问题。
另外PTA12 PTB0这几个脚,手册里注明了是强驱动引脚,我如果输出为高的话,电流就会增加,只有当输出为低或置为输入时才可以,不知道是什么原因。
|
|