关于LPC1766 GPIO 2.2~2.5 的控制没反应 求助下高手 :)
各位朋友,在程序里 开起了 uart0 timer0, 准备在P2.2至P2.5,定时输出高低电平,以控制led亮灭。uart0 和 timer0 都工作正常, 但是 GPIO 2.2~2.5 就是不听话,请大家看看 问题在哪里:
int main (void)
{
//uint32_t data, true_data, i;
uint8_t times=100 ;
TargetResetInit();
NVIC_DeInit();
NVIC_SCBDeInit();
#if __IRAM
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
/* Configure the NVIC Preemption Priority Bits */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
SysTick_Config(100000000UL/1000 - 1);
UARTInit(0, 115200);
// UART0 TESTing
while (times>=1)
{
UART0SendByte(64);
times--;
printf("hello\r\n");
};
if (InitialTimer( 0 , 50000 )) // interval is 1ms.
{ EnableTimer (0); printf(" Timer 0 is enabled.\r\n");}
else printf (" Timer 0 not initialized.\r\n");
// Four Leds are connected to P2.2 ~ P2.5
// Set P2.2 ~ 2.5 to GPIO functions.
PINSEL4 &= (~(0x3c));
PINMODE4 &= (0x00000550);
PINMODE4 |= (0x00000550);
FIO2DIR0 |= 0x3c ;
FIO2MASK0 &= (~(0x3c));
// 初始化I2C接口/* initialize I2c
// I2CInit( (unsigned int)I2CMASTER );
printf("I2C2 is initialized .\r\n");
putch(64);
putch(13);
putch(10);
puts("hello!");
// GPIO and Timer testing:
while (1)
{ FIO2SET0 |= 0x3c;
// FIO2PIN0 |= 0x3c;
System_wait(1000);
puts("I set");
FIO2CLR0 |= 0x3c;
// FIO2PIN0 &= (~(0x3c));
System_wait(1000);
puts (" and then I reset.\r \n");
};
管脚配置不对 tjjack 发表于 2013-12-17 16:06
管脚配置不对
请明示 谢谢。{:smile:} 搞定了 查到后来 发现是LPC17xx.h 地址错误真是晕啊{:sweat:} 这种参考文档 真是锻炼人!!!
页:
[1]