STM32L15XXX 入门笔记

摘要:
}external_IOuint32_t定时延迟;GPIO_ InitStructure.GPIO_ Mode=GPIO_ Mode_ OUT;GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;GPIO_初始化结构.GPIO_速度=GPIO_速度_ 40MHz;

一、系统时钟默认是32M,最高支持32M,不过下图已经改成72M也可以运行,可能会有什么后遗症,位置在

STM32L15XXX 入门笔记第1张

二、定时器1ms两种方法
1、Main.c里

void delay_nms(uint32_t time)
{
uint32_t i=0;
while(time--)
{
i=12000; //自己定义
while(i--) ;
}
}

这种方式多少有点不准确。
2、在Stm32l1xx_it.c文件下,加入以下代码,注意SysTick_Handler已经存在

void Init_SysTick(void)
{
if(SysTick_Config(SystemCoreClock / 1000)) //注意:3.5库中 SystemFrequency 被 SystemCoreClock 取代。
while(1);
}
__IO uint32_t TimingDelay;
void delay_ms(__IO uint32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
extern __IO uint32_t TimingDelay;
void SysTick_Handler(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}

然后再main里

Init_SysTick();

Delayms(1000);即可延时1ms.

三、控制LED闪烁,LED外接在PB1上,和STM32F10系列多少有点不一样

int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32l1xx_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32l1xx.c file
*/
/* GPIOD Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);//使用AHB不是APB
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure PD0 and PD1 or PD3 and PD7 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOB, &GPIO_InitStructure);

/* Add your application code here
*/
//Init_SysTick();
/* Infinite loop */
while (1)
{
GPIOB->BSRRL = 0x02;
delay_nms(1000);
GPIOB->BSRRH = 0x02;
delay_nms(1000);
}
}

免责声明:文章转载自《STM32L15XXX 入门笔记》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇ORB-SLAM2 源码学习 &amp;lt;一&amp;gt; 源码框架简析python基础之字符编码下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

oracle读写文件--利用utl_file包对磁盘文件的读写操作

摘要: 用户提出一个需求,即ORACLE中的一个表存储了照片信息,字段类型为BLOB,要求能导出成文件形式. 本想写个C#程序来做,后来想起ORACLE有很多包,功能很好很强大,于是网上参考了些文章完成了. 主要是用了ORACLE的两个包:UTL_FILE和DBMS_LOB. 实现过程: 第一步:以管理员用户登陆设置可操作目录 --CREATE...

在Visual C++ 中使用内联汇编 冷夜

一、 优点     使用内联汇编可以在 C/C++ 代码中嵌入汇编语言指令,而且不需要额外的汇编和连接步骤。在 Visual C++ 中,内联汇编是内置的编译器,因此不需要配置诸如 MASM 一类的独立汇编工具。这里,我们就以 Visual Studio .NET 2003 为背景,介绍在 Visual C++ 中使用内联汇的相关知识(如果是早期的版本,可...

state thread

State Thread 的官网地址:http://state-threads.sourceforge.net The State Threads Library is a small application library which provides a foundation for writing fast and highly scalable I...

Windows异常处理机制介绍

转自:http://hi.baidu.com/zwegpcwvtybivxq/item/a8b7e6c15e8b15155150581f 最近做了一个Windows下的异常处理模块,查阅了一些新的资料,结合我自己的理解,将一些点滴记录如下,希望对兄弟们有所帮助。 一、C++标准异常 也就是try、throw、catch这三个关键字。 try{    …… ...

OpenStack 中的neutron-server启动过程

neutron-server是neutron的核心组件之中的一个。负责直接接收外部请求,然后调用后端对应plugin进行处理。 其核心启动过程代码主要在neutron.server包中。 __init__.py文件里包含一个main()函数,是WSGIserver開始的模块,而且通过调用serve_wsgi来创建一个NeutronApiService的...

suricata的模块和插槽

参考资料 suricata官方文档https://suricata.readthedocs.io/en/latest/performance/runmodes.html#different-runmodes suricata的源代码https://blog.csdn.net/shenwansangz/article/details/37900875?utm...