如题,本人刚入手stm8l系列单片机,目前是在ST官网上下载了固件库,想试一下GPIO的操作。。。
按照固件库里面的程序例程,自己建了一个Project,编译通过后,看不到PB0,PD0口的电平Toggle。。。
main程序如下(基本上和ST给的程序一样):
#include "stm8l10x.h"
#include "stm8l10x_gpio.h"
void Delay(__IO uint16_t nCount);
void main(void)
{
// GPIO_DeInit(GPIOB);
//GPIO_DeInit(GPIOD);
GPIO_Init(GPIOB, GPIO_Pin_0, GPIO_Mode_Out_PP_Low_Fast);
GPIO_Init(GPIOD, GPIO_Pin_0, GPIO_Mode_Out_PP_Low_Fast);
while(1)
{
GPIO_ToggleBits(GPIOB, GPIO_Pin_0);
GPIO_ToggleBits(GPIOD, GPIO_Pin_0);
Delay(0xFFFF);
}
}
void Delay(__IO uint16_t nCount)
{
/* Decrement nCount value */
while (nCount != 0)
{
nCount--;
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{}
}
#endif
硬件电路图如附件。
还请各位大牛不吝解惑,在线等,谢谢! |